繁体   English   中英

Visual Studio:“信任证书失败”

[英]Visual Studio: "Failed trusting the certificate"

On Windows 10/11, With Visual Studio 2017-2022, when serving a web API via HTTPS with Kestrel or IIS, Visual Studio prompts me to trust the self-signed certificate that ASP.NET Core has generated.

如果我单击“是”,我会收到以下错误:

将证书添加到受信任的根证书存储失败并出现以下错误:信任证书失败。 (运行 Kestrel)或访问被拒绝。 (运行 IIS)

通过 Chrome 导航到 swagger UI 页面验证证书确实无效并且连接不安全。

运行dotnet dev-certs https --trust结果

信任 HTTPS 开发者证书时出错。

从 certmgr 我可以看到 ASP.NET 核心 HTTPS 开发证书已安装在当前用户/个人商店中。 我还看到了Trusted Root Certification Authorities -store 和里面的证书。

如果我尝试将证书拖放到 Trusted Root Certification Authorities -store,我会收到以下错误消息:

无法将证书粘贴到受信任的根证书颁发机构 - 存储中。 访问被拒绝。

如果我尝试将证书导入所述商店,我会收到以下错误消息:

导入失败,因为存储是只读的、存储已满或存储未正确打开。

如果我尝试从导出的文件安装证书,通过'Install certificate' -> 'Current User' -> 'Place all certificates in the following store' -> Browse ,我看不到Trusted Root Certification Authorities -store一点也不。

如果我 select 'Certificates - Current User' -header, go to View -> Options, and enable 'Physical certificate stores' ,我可以将证书拖放到物理存储Trusted Root Certification Authorities/Local Computer/Certificates

该证书现在在受信任的根证书颁发机构存储中可见,但 Visual Studio 仍然抛出相同的错误,浏览器认为该证书不受信任,并且dotnet dev-certs https --check --trust输出:

未找到有效证书。

如果我将原始证书留在Personal中,则在没有私钥的情况下将其导出并将导出导入实体店Trusted Root Certification Authorities/Local Computer/Certificatesdotnet dev-certs https --check --trust打印:

找到受信任的证书:...

...但浏览器仍然认为证书无效,并且 Visual Studio 会抛出错误。

dotnet run的结果相同,在 Visual Studio 中没有信任错误。 dotnet CLI 似乎不检查或尝试信任证书。

相同但不同:如果我从 Chrome 保存证书并尝试通过Chrome -> Settings -> Privacy and security -> Manage certificates -> Trusted Root Certification Authorities -> Import将其添加到Trusted Root Certification Authorities ,我也会收到:

导入失败,因为存储是只读的、存储已满或存储未正确打开。

我已经用完了可以尝试的东西,而且我可能缺少一些基本的东西。 我应该怎么办?

事实证明,虽然我确实删除了用户和机器存储中的所有 localhost 证书,并重新安装了 IIS,但在此过程中安装了某种错误的 localhost 证书,我需要再次删除它们,然后将浏览器中可见的安装到本地计算机证书受信任的根证书存储。

希望这对将来的某人有所帮助。 始终检查您的序列号。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM