PHP连接grpc时怎么跳过tls认证?
这是golang连接grpc服务的代码,是可以正常连接调用的
func main() {
dialCred := grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{InsecureSkipVerify: true}))
conn, err := grpc.Dial(":10000", grpc.WithUnaryInterceptor(UnaryClientInterceptor), dialCred)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}
这是php链接grpc服务的代码
private function callClient(string $func, \Google\Protobuf\Internal\Message $param, \Google\Protobuf\Internal\Message $rep, int $attempts)
{
$this->client = new \Client\ServiceClient($this->service_host, [
'credentials' => \Grpc\ChannelCredentials::createInsecure(), //不加密
'timeout' => 3000000, //3s
]);
list($reply, $status) = call_user_func([$this->client, $func], $param, $this->getXParams())->wait();
var_dump($reply, $status);
}
下面是php调用的打印结果
NULL object(stdClass)#1862 (3) { ["metadata"]=> array(0) { } ["code"]=> int(14) ["details"]=> string(13) "Socket closed" }
问题?
//golang连接grpc时的这个跳过服务端tls验证对应php代码要怎么设置?
dialCred := grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{InsecureSkipVerify: true}))
用的哪个包呢
credentials => null 就可以了