如何解决运行 dev-certs https --trust 后,dotnet run 报错找不到默认的开发者证书
我们阅读了this documentation。
我们在 PowerShell 中运行了以下内容:
dotnet dev-certs https --clean
dotnet dev-certs https --trust
dotnet dev-certs https --check # none found :-(
然后我们打开一个新的 PowerShell 会话并运行:
dotnet dev-certs https --check # still none found :-(
dotnet run
这是错误信息。
System.InvalidOperationException
:无法配置 HTTPS 端点。未指定服务器证书,默认开发者证书找不到或已过期。
这是dotnet --info
的输出
.NET SDK (reflecting any global.json):
Version: 5.0.302
Commit: c005824e35
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.302\
Host (useful for support):
Version: 5.0.8
Commit: 35964c9215
我们如何将 dotnet run
指向我们使用 dotnet dev-certs https --trust
创建的证书?
解决方法
基于https://stackoverflow.com/a/65266499/1108891,我们手动删除了localhost颁发的所有证书,然后重复我们的步骤。这就是我们删除所有本地主机颁发的证书的方式。
Get-ChildItem -Path Cert:\CurrentUser -Recurse `
| Where { $_.PSISContainer -eq $false } `
| Where { $_.Issuer -match 'localhost' } `
| Remove-Item -Whatif;
Get-ChildItem -Path Cert:\LocalMachine -Recurse `
| Where { $_.PSISContainer -eq $false } `
| Where { $_.Issuer -match 'localhost' } `
| Remove-Item -Whatif
-Whatif
用于避免复制/粘贴破坏不知情的读者的证书存储。我们在运行此步骤时将其删除。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。