I have created an sample ASP.NET Core
application using command line:
dotnet new
and tried to run it utilizing command:
dotnet run
But, when opening the URL in the browser, it complains that the SSL is invalid.
I can run the program using Visual Studio
full version without any problem, but can not run it using command line:
dotnet run
Seems that Kestrel
which is run by command dotnet run
needs extra configurations.
Now, the question is how can I run my ASP.NET Core
application over https
using Kestrel
?
I'm on Dot Net Core 2.2
and Visual Studio 2019
When you run ASP.NET Core in development mode using dotnet run
, or from within Visual Studio, then there is already built-in support for a development certificate that allows you to develop right away with HTTPS support.
The development certificate is built-in with the .NET Core SDK and usually it should set it self up when you run the .NET Core SDK for the first time. If that did not work or if you lost the development certificate for some reason, then you can always install it later using the following command:
dotnet dev-certs https --trust
This part is also described in the “Enforcing SSL” chapter of the official documentation.
Note that the development certicate only applies during development and of course you will need to set up a proper certificate for production later. How that works of course depends on how you are going to host the application later. The different options and how to configure SSL is covered in the hosting chapter.