4
votes

I'm trying to replicate what Visual Studio does on F5 debugging in my .net core api application.

It seems that "dotnet run --project" is the trick that I'm looking for except for one thing:

When I run with F5, it runs on https and it is trusted. When I run with dotnet run, it runs on https and it is NOT trusted.

And I seem to be having problems using the application even though it seems to be running.

Any thoughts? I would like to do the same trick that F5 does just in order to test my application, however dotnet run must be missing some sort of certificate or something?

I really don't want to have to change my source code or to do anything with certs, again, because it is working as designed on F5, just need to do the same trick for dotnet run.

1
What editor or IDE are you exactly working on? F5 is handled by many editors. - Alsein
@Alsein I think OP's point is more that it runs from Visual Studio (which is supplying its local development SSL certficiate that's registered with the machine), whereas using dotnet run -https isn't using this certificate. - Llama
Whether it is trusted depends on the browser's trusting policy. So if your IDE passes some arguments when launching the browser to specify a development certificate to be trusted, it would work properly. - Alsein
@John Then Visual Studio must be explicitly specified by OP. - Alsein
I've been trying to find that out. So far I've got as far as a GitHub issue about trusting development certs. - Llama

1 Answers

6
votes

Based on the documentation here, it seems like you need to install and trust the development certificate:

.NET Core SDK includes a HTTPS development certificate. The certificate is installed as part of the first-run experience.

While the certificate is installed at this stage, it goes on to say that:

Installing the .NET Core SDK installs the ASP.NET Core HTTPS development certificate to the local user certificate store. The certificate has been installed, but it's not trusted. To trust the certificate perform the one-time step to run the dotnet dev-certs tool.

To trust it, you should use the following command:

dotnet dev-certs https --trust

This should show a dialog prompting you to trust the certificate. Once this is done, you can start your project running again, and restart your browsers. This should allow you to access the site on https://localhost:portnumber