Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date 的解决办法-程序旅途

今天 VS2019 运行项目,因为配置了SSL,报了下面的错误

Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.
To generate a developer certificate run ‘dotnet dev-certs https’. To trust the certificate (Windows and macOS only) run ‘dotnet dev-certs https --trust’.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.

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 dev-certs https’生成一个新的证书,依然提示找不到证书。

解决办法

执行下面的命令,查看 dev-certs https 的参数

dotnet dev-certs https -h

Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date 的解决办法-程序旅途

可以看到有一个 --clean 参数,它可以清除本机所有的https开发证书

执行带 --clean 的命令

dotnet dev-certs https --clean

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 dev-certs https -t

Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date 的解决办法-程序旅途

然后重启 VS2019,问题解决