【问题标题】:After running dev-certs https --trust, dotnet run complains that the default developer certificate could not be found运行 dev-certs https --trust 后,dotnet run 报错找不到默认的开发者证书
【发布时间】:2021-09-23 17:45:15
【问题描述】:

我们阅读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 创建的证书?

【问题讨论】:

标签: c# ssl .net-core windows-10 dotnet-cli


【解决方案1】:

基于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 用于避免复制/粘贴破坏不知情的读者的证书存储。我们在运行此步骤时将其删除。

【讨论】:

    猜你喜欢
    • 2019-08-24
    • 1970-01-01
    • 2021-01-09
    • 2019-04-17
    • 2019-12-04
    • 2020-05-01
    • 2022-10-17
    • 2021-10-27
    相关资源
    最近更新 更多