System.InvalidOperationException:“Unable to configure HTTPS endpoint.异常处理
2023-01-13 3403 0
.NET Core网站按F5运行时,在Program.cs里运行到app.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.
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.”

解决方法是在CMD命令提示符里输入以下命令生成开发人员证书:
dotnet dev-certs https这样网站就可以运行了,但是会提示证书不安全。
继续运行以下命令信任证书。
dotnet dev certs https--trust这样就不会提示证书不安全了。
清理开发人员证书的命令是:
dotnet dev-certs https --clean