punkouter
punkouter

Reputation: 5366

How to fix HTTPS Certificate Error when running ASP.NET Core web app in VSCode

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 ?

Upvotes: 8

Views: 13263

Answers (2)

AHAMED AAQIB
AHAMED AAQIB

Reputation: 493

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"
      }
    }
  }
}

Upvotes: 4

Reza Aghaei
Reza Aghaei

Reputation: 125197

Follow these steps:

  1. Open terminal
  2. Run dotnet dev-certs https --trust and confirm the dialog
  3. Close VSCode
  4. 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

Upvotes: 9

Related Questions