使用ASP Net Core开发的一个站点,启动的时候报错:Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found.经过分析主证书的事情,现在由VS默认的Web站点都是支持证书配置的,我们在开发的时候会默认要求安装证书,如果证书出现问题后可能就会引起以上错误。

那我们应该怎么解决呢?

(1)关闭浏览器

(2)打开命令行运行以下命令:

dotnet dev-certs https --clean
dotnet dev-certs https -t

(3)运行以下命令检查安装的证书

dotnet dev-certs https --check


如果 以上命令什么都没有返回就代表着一切正常。

再次运行我们的ASP Net Core站点发现正常了。

FATAL Microsoft.AspNetCore.Server.Kestrel.LogMessage [0] - MESSAGE: Unable to start Kestrel.
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.
at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action`1 configureOptions)
at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IServerAddressesFeature addresses, KestrelServerOptions serverOptions, ILogger logger, Func`2 createBinding)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)