在 运行ning dev-certs https --trust 之后,dotnet 运行 抱怨找不到默认的开发者证书
After running dev-certs https --trust, dotnet run complains that the default developer certificate could not be found
我们 运行 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
: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.
这是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.0.302\
Host (useful for support):
Version: 5.0.8
Commit: 35964c9215
我们如何将 dotnet run
指向我们用 dotnet dev-certs https --trust
创建的证书?
基于,我们手动删除了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
是为了避免 copy/paste 破坏不知情的 reader 的证书存储。我们在 运行 这一步时删除了它。
我们 运行 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
: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.
这是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.0.302\
Host (useful for support):
Version: 5.0.8
Commit: 35964c9215
我们如何将 dotnet run
指向我们用 dotnet dev-certs https --trust
创建的证书?
基于
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
是为了避免 copy/paste 破坏不知情的 reader 的证书存储。我们在 运行 这一步时删除了它。