ssl - .NET Core 在处理 HTTPS 证书时出现未知错误

标签 ssl .net-core ssl-certificate kestrel-http-server

<分区>


这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这个问题的解决方式不太可能帮助 future 的读者。

关闭 3 年前

我正在尝试构建一个使用 HTTPS 连接的 .NET Core 服务器。

我使用 dotnet dev-certs 工具创建了一个自签名证书,并且 像这样设置 Kestrel:

    return WebHost.CreateDefaultBuilder(args)
                    .UseKestrel(options =>
                    {
                        options.Listen(IPAddress.Loopback, 5000, lisOpt => lisOpt.UseHttps("myCert.pfx", "test"));
                    })
                  .UseStartup<Startup>()
                .Build();

但是当我尝试与我的客户端连接时,我不断收到此异常:

fail: Microsoft.AspNetCore.Server.Kestrel[0]
      Uncaught exception from the OnConnectionAsync method of an IConnectionAdapter.
System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> System.ComponentModel.Win32Exception: An unknown error occurred while processing the certificate
   --- End of inner exception stack trace ---
   at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, ExceptionDispatchInfo exception)
   at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
--- End of stack trace from previous location where exception was thrown ---
   at System.Net.Security.SslState.ThrowIfExceptional()
   at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
   at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)
   at System.Net.Security.SslStream.EndAuthenticateAsServer(IAsyncResult asyncResult)
   at System.Net.Security.SslStream.<>c.<AuthenticateAsServerAsync>b__50_2(IAsyncResult iar)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionAdapter.InnerOnConnectionAsync(ConnectionAdapterContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.FrameConnection.ApplyConnectionAdaptersAsync()
fail: Microsoft.AspNetCore.Server.Kestrel[0]
      Uncaught exception from the OnConnectionAsync method of an IConnectionAdapter.
System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> System.ComponentModel.Win32Exception: An unknown error occurred while processing the certificate
   --- End of inner exception stack trace ---

我做错了什么?

最佳答案

这显然是因为我的客户端将请求发送到 127.0.0.1 而不是“localhost”。

关于ssl - .NET Core 在处理 HTTPS 证书时出现未知错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55317637/

上一篇:docker - SSL 代理通过 NGINX 通过 Docker 导致网关错误

下一篇:amazon-web-services - 我可以在没有负载均衡器的情况下为 AWS lightsail 设置 ssl 证书吗?

相关文章:

asp.net-core - Azure,错误 403 - 禁止 : Client Certificate Required

ios - 在 iPhone 模拟器上成功安装证书后,在访问我的 Web 服务时仍然出现 SSL 错误

azure - 在azure应用程序服务上公开TLS/SSL服务器

java - 解决 javax.net.ssl.SSLHandshakeException : sun. security.validator.ValidatorException : PKIX path building failed Error?

ssl - 玩 WS SSL acceptAnyCertificate=true 问题

ssl - 如何在网站之间共享自签名 TLS 证书

windows - 访问 nginx 后面的 Windows Admin Center

.NET core 3.0 和 MS Office Interop

.net - DotNet 似乎允许两个进程打开同一个端口?

c# - 在 dotnetcoreapp2.0 中使用 UnobservedTaskException 处理程序