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}))
_YangCong
讨论数量: 3

用的哪个包呢

10个月前 评论
_YangCong (楼主) 10个月前

credentials => null 就可以了

10个月前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!