我使用git并运行示例:https://github.com/grpc/grpc-dotnet/tree/master/examples/Greeter
它使用Grpc.Net.Client
。
此软件包不适用于非核心应用程序。
我所有的搜索都指向Grpc.Core.Channel
来取代var channel = GrpcChannel.ForAddress("https://localhost:5001");
我多次尝试将dotnet4.6应用程序连接到前面引用的git提供的服务。
Channel channel = new Channel("localhost", 5001, ChannelCredentials.Insecure);
SslCredentials ssl = new SslCredentials();
Channel channel = new Channel("localhost", 5001, ssl);
Channel channel = new Channel("localhost", 5001, ChannelCredentials.Insecure,
new List<ChannelOption> {
new ChannelOption("InsecureSkipVerify", "True") });
当我将服务设置从"applicationUrl": "https://localhost:5001"
编辑为"applicationUrl": "http://localhost:5001"
时,我得到的唯一成功
然后使用
Channel channel = new Channel("localhost", 5001, ChannelCredentials.Insecure);
没问题。
那么,有没有办法通过https访问(无需身份验证)该服务呢?
发布于 2020-04-30 18:09:00
我认为来自https://github.com/grpc/grpc-dotnet/tree/master/examples/Greeter/Server的服务器不会在https下公开服务(您必须相应地指定选项并使用服务器端证书)。其他示例演示了如何创建支持https的(安全)服务器。
一旦您设置了一个实际公开https的服务器:在客户端,您需要指定与服务器使用的证书相对应的证书根,否则连接将被拒绝。
请随意参考此处的示例:https://github.com/jtattermusch/grpc-authentication-kubernetes-examples和此处的https://github.com/grpc/grpc-dotnet/blob/master/examples/Certifier/
https://stackoverflow.com/questions/61390508
复制相似问题