ssl - 带有 localhost 自签名证书的 Grpc.core TLS 握手
问题描述
我有一个 gRPC 服务在我的本地机器上运行,它需要通过 TLS 的请求。
当我使用 Grpc.Net.Client 库时,以下工作:
var channelGrpcNetClient = GrpcChannel.ForAddress("https://localhost:5003");
var clientGrpcNetClient = new ProvisionClient(channelGrpcNetClient);
await clientGrpcNetClient.CreateAsync(createRequest);
但是,当我尝试在 Grpc.Core 中做类似的事情时,它不再起作用了
var channelGrpcCore = new Channel("https://127:0:0:1", 5003, new SslCredentials());
var clientGrpcCore= new ProvisionClient(channelGrpcCore );
await clientGrpcCore.CreateAsync(createRequest);
这是我得到的例外:
Grpc.Core.RpcException: 'Status(StatusCode="Unavailable", Detail="无法连接到所有地址", DebugException="Grpc.Core.Internal.CoreErrorDetailException: {"created":"@1622691838.697000000","description" :"未能选择子频道","file":"......\src\core\ext\filters\client_channel\client_channel.cc","file_line":5420,"referenced_errors":[{"created" :"@1622691838.697000000","description":"连接所有地址失败","file":"......\src\core\ext\filters\client_channel\lb_policy\pick_first\pick_first.cc", "file_line":398,"grpc_status":14}]}")'
Grpc.Core 库是否不允许使用 localhost 自签名证书的 TLS 连接?似乎 Grpc.Core 使用 BoringSSL,它与 Grpc.Net.Client 使用的库不同。我想知道这个问题是否有解决方法,允许在本地运行客户端和服务器,并且只使用自签名证书。
解决方案
推荐阅读
- google-apps-script - 从另一个 Apps Script 项目运行 Apps Script Web App 时如何以编程方式进行身份验证
- ssh - 在另一个出口点使用wireguard服务器和隧道出口流量
- scala - sbt 程序集重复数据删除:在以下位置找到不同的文件内容:jackson-annotations
- java - 如何通过不同的方法将相同的实体放入 EhCache
- php - PHP - SSAS - MSOLAP ISAPI 扩展 msmdpump.dll 访问被拒绝
- python - 从稀疏矩阵中获取一系列奇异值
- rust - 是否可以提供可链接特征方法的默认实现?
- javascript - How to push element to the last place in the array
- amazon-web-services - AWS CDK:停止 EC2 队列中的 Spot 实例
- python - facebook messenger 和 dialogflow:: 从多个通用模板按钮中分别检测每个事件