Problem:
During development in Visual Studio, ASP.Net Core WebAPI project started throwing this error.
Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found. To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
Solution:
As suggested in the error message, we have to run the command dotnet dev-certs https
.
- First close the browser or stop Visual Studio debugger if you are directly running from Visual Studio.
-
Open the command prompt, go to the project's root folder and run this command.
dotnet dev-certs https --clean
It cleans all HTTPS development certificates from the machine. It will give you following message.
Cleaning HTTPS development certificates from the machine. A prompt might get displayed to confirm the removal of some of the certificates.
It may give you a prompt for the removal of certificate, if so, just accept.
-
Second run this command:
dotnet dev-certs https -t
To make it trust the certificate on the current platform.