Home > Mobile >  How to configure a custom cert and key for a .NET Core application for Rider or Visual Studio soluti
How to configure a custom cert and key for a .NET Core application for Rider or Visual Studio soluti

Time:11-04

Visual Studio 2019 and Jetbrains Rider .NET Core (and possibly other) projects register a "localhost" root certificate on the system, and then when launching and debugging .NET Core applications, they run the web service using certs and keys that validate against that localhost root cert.

I have my own root cert and want to run under a custom domain, lan.company.com, which also has it's own custom cert and key. How do I configure the project or IDE to use a particular cert and key when serving the app?

CodePudding user response:

The simplest and clearest solution is to add the following to the project's appsettings.json:

"Kestrel": {
  "Endpoints": {
    "HttpsFromPem": {
      "Url": "https://lan.company.com:5001",
      "Certificate": {
        "Path": "./certs/lan.company.com.crt",
        "KeyPath": "./certs/lan.company.com.key"
      }
    }
  }
}

Then revise the launchSettings.json applicationUrl: "applicationUrl": "https://lan.company.com:5001"

This all assumes that you already have a trusted root certificate and the custom domain cert and key.

  • Related