I have move to using VSCode instead of VS2019 but noticed this error comes up when I run.. It still works.. I just need to keep clicking to ignore the error. Is there some easy fix for this ?
-
Wondering the same thing. Visual Studio installs a certificate for localhost. wondering if there's a way to do the same from VS Code. have you been able to figure it out?Luis Mejia– Luis Mejia2020-04-19 22:44:15 +00:00Commented Apr 19, 2020 at 22:44
-
surprised I couldn't find an easy answer since it must be happening to a lot of people.. I just switched back to VS2019 .. ended up really missing intellisense things for c#punkouter– punkouter2020-04-21 14:57:39 +00:00Commented Apr 21, 2020 at 14:57
-
I had the same issue and I fixed it using the command that I've shared in the answer.Reza Aghaei– Reza Aghaei2021-04-20 10:19:25 +00:00Commented Apr 20, 2021 at 10:19
Add a comment
|
2 Answers
Follow these steps:
- Open terminal
- Run
dotnet dev-certs https --trustand confirm the dialog - Close VSCode
- Close all browser instances
To find more information, take a look at:
You may find the following commands useful:
- Clear developer certificate:
dotnet dev-certs https --clean - Generate a developer certificate:
dotnet dev-certs https - Trust developer certificate:
dotnet dev-certs https --trust
3 Comments
G J
Command is
dotnet dev-certs https --cleanReza Aghaei
@GJ Correct. Thanks for catching that! 🙌 (I don't remember if --clear was really supported that time or it was a typo 😅)
iCode
In some cases, you might need to restart the browser after clearing the dev certs and trusting.
Open the terminal/CLI and run the below command (select the preferred profile - http or https or "IIS Express") from the launchsettings.json file of your .NET project
dotnet run --launch-profile https
Sample launchSettings.json below
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:62471",
"sslPort": 44313
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5281",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7260;http://localhost:5281",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
2 Comments
iCode
Thank you, @AHAMED AAQIB. It seems that the default profile that was getting launched was
http and it needed to launch the https profile. I also found out that the first profile listed in launchsettings.json appears to be the default profile that is launched according to an answer to the what-is-dotnet-run-default-profile-setting-from-launchprofile-json post: stackoverflow.com/a/70615515/1617161AHAMED AAQIB
@iCode Yes you are right default profile is
http. Also when we run dotnet run command it automatically picks up the default (First) profile. It is best practice to run through https profile to avoid errors such as connect ECONNREFUSED