【发布时间】:2019-12-08 14:36:26
【问题描述】:
我仅从 VS 2017 模板对话框中创建了一个 .NET Core Web 应用程序,并启用了“为 HTTPS 配置”。
我用过
dotnet dev-certs https --trust
并确认提示。我向 MMC 检查了 localhost 证书是否存在于 CurrentUser/My 中。
当我现在运行应用程序时,Firefox 只会显示我(我不知道确切的英文翻译)
连接到 https//localhost:44371 时出错 PR_CONNECT_RESET_ERROR
Chrome 也显示以下错误,
ERR_CONNECTION_RESET
我也禁用了 Windows 防火墙,但结果是一样的。
当我在项目调试属性中取消选中启用 SSL 时,站点显示良好但没有 HTTPS。
任何人都知道可能出了什么问题,或者我可以在 Github 哪里找到查找证书的代码?
更新 1:
我从使用 IIS Express 的 Visual Studio (2017) 启动应用程序切换到 Kestrel,它会打开控制台窗口并告诉我更多信息:
info: Microsoft.AspNetCore.Server.Kestrel[20]
Connection id "0HLOLGRVN8U0U" request processing ended abnormally.
System.IO.IOException: The decryption operation failed, see inner exception. ---
> System.ComponentModel.Win32Exception: Beim Verarbeiten des Zertifikats ist ein
unbekannter Fehler aufgetreten
--- End of inner exception stack trace ---
at System.Net.Security.SslStreamInternal.ReadAsyncInternal[TReadAdapter](TRea
dAdapter adapter, Memory`1 buffer)
at Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal.AdaptedPipeline.
ReadInputAsync(Stream stream)
at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()
at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
at System.IO.Pipelines.Pipe.GetReadAsyncResult()
at System.IO.Pipelines.Pipe.DefaultPipeReader.GetResult(Int16 token)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.Proces
sRequests[TContext](IHttpApplication`1 application)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.Proces
sRequestsAsync[TContext](IHttpApplication`1 application)
System.ComponentModel.Win32Exception: Beim Verarbeiten des Zertifikats ist ein unbekannter Fehler aufgetreten
已翻译
System.ComponentModel.Win32Exception:处理证书时发生未知错误
在 Kestrel Firefox 下,至少会显示我可以信任自签名证书的页面并显示该页面。 (但现在在不同的端口 5001 用于 https 和 5000 用于 http)。 Chrome 不要求信任证书,只是按预期工作。
对我来说似乎是证书和/或 IIS Express 的问题。
找到that one,虽然这是一个不同的问题。
【问题讨论】:
-
我认为你甚至不需要运行 dotnet dev--certs 的东西。它应该开箱即用。我从来没有运行过它,总是使用 https
-
是的,dev-certs 命令以防万一没有本地主机 SSL 证书。由于我将它们全部删除(因为我正在尝试使用证书)我需要确保我有一个。
-
当您在 IIS Express 上托管网站时,SSL Diag 可以揭示典型问题docs.jexusmanager.com/tutorials/ssl-diagnostics.html 当您直接在 Kestrel 上托管它时,您很可能需要在 Kestrel 中进行调试以了解问题所在。
-
您找到解决方案了吗?我有同样的问题。
标签: c# .net-core ssl-certificate iis-express .net-core-2.2