Monday, January 11, 2021

Visual Studio Code: Fixing Error "Your connection is not private" (NET::ERR_CERT_AUTHORITY_INVALID)

 When debugging/running a web service or web application in Visual Studio Code or Visual Studio the following error will show up in the browser the first time an application is run immediately after the .NET 5 (or other) SDK is installed:


The text of the error is: 

Your connection is not private

Attackers might be trying to steal your information from localhost (for example, passwords, messages, or credit cards). Learn more

NET::ERR_CERT_AUTHORITY_INVALID

The error is caused because the certificates used during running/debugging provided by the .NET 5 SDK have not been trusted on the local host. The DotNet CLI provides a command-line for trusting these certificates:

dotnet dev-certs https --trust

The command above should be run from Visual Studio Code's Terminal window:


When the above command is invoked, the following dialog is displayed:


Click on Yes to trust the certificates. Restart the application being debugged/run in Visual Studio code and the error should disappear. 

1 comment :