Search code examples
c#.netasp.net-core.net-coredotnet-cli

dotnet run --project issue with https


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.


Solution

  • 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