gpt4 book ai didi

https - 在 .Net 5 : UntrustedRoot 下使用 HTTPS 调用 gRPC 服务的证书错误

转载 作者:行者123 更新时间:2023-12-04 03:42:24 26 4
gpt4 key购买 nike

我正在尝试使用 HTTPS 连接我的 gRPC 客户端和服务,它们都在我本地 Windows 10 机器上的 .Net 5 下运行。现在我收到此证书错误,但不知道如何解决:

    Status(StatusCode=\"Internal\", Detail=\"Error starting gRPC call. 
HttpRequestException: The SSL connection could not be established, see inner exception.

AuthenticationException: The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot\", DebugException=\"System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.\r\n
---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot\r\n at System.Net.Security.SslStream.SendAuthResetSignal(ProtocolToken message, ExceptionDispatchInfo exception)\r\n at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)\r\n at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Boolean async, Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)\r\n --- End of inner exception stack trace ---\r\n at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Boolean async, Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpConnectionPool.GetHttp2ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)\r\n at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)\r\n at Grpc.Net.Client.Internal.GrpcCall`2.RunCall(HttpRequestMessage request, Nullable`1 timeout)\")
我试图通过运行下面的推荐来安装开发证书,但似乎已经存在一个:
enter image description here
看来我在我的个人和受信任的根存储下都有这个证书
enter image description here
enter image description here
但是,我确实注意到,我的商店中存在的证书是“IIS Express 开发证书”,而不是“ASP.NET Core HTTPS 开发证书”。有关系吗?如果是这样,我如何安装正确的证书?如果没有,我还缺少什么?

最佳答案

如果有人感兴趣 - 就我而言,这是由于在我当前的 Windows 构建级别下 IIS 不支持 gRPC 托管。在等待 MS 完成解决方案时,我刚刚将以下内容添加到我的 gRPC 客户端:

    var httpHandler = new HttpClientHandler();
httpHandler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
var channel = GrpcChannel.ForAddress(ServerAddress, new GrpcChannelOptions { HttpHandler = httpHandler });
如您所见,此代码是临时的,不用于生产。微软最近表示,该支持已包含在操作系统的 build 20241 或更高版本中,我计划在 future 几周内对其进行测试。

关于https - 在 .Net 5 : UntrustedRoot 下使用 HTTPS 调用 gRPC 服务的证书错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65741637/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com