首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在DotNet4.6应用程序中使用Grpc.Core并在不进行身份验证的情况下使用https是否可能,以及如何使用

在DotNet4.6应用程序中使用Grpc.Core并在不进行身份验证的情况下使用https是否可能,以及如何使用
EN

Stack Overflow用户
提问于 2020-04-23 23:06:39
回答 1查看 220关注 0票数 0

我使用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提供的服务。

代码语言:javascript
运行
复制
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"时,我得到的唯一成功

然后使用

代码语言:javascript
运行
复制
Channel channel = new Channel("localhost", 5001, ChannelCredentials.Insecure);

没问题。

那么,有没有办法通过https访问(无需身份验证)该服务呢?

EN

回答 1

Stack Overflow用户

发布于 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/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61390508

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档