Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add SSl certificate to Kestrel in .Net core

I have a valid SSL certificate with a base64 format key. I have added the certificate using Nginx. but not working. routing is still hitting HTTP, not hitting HTTPS.network team suggest me to add a certificate directly to kestrel.

appsettings.json

 "Kestrel": {
    "https_port": 443,
    "EndPoints": {
      "Https": {
        "Url": "https://*:7003"
      }
    }
  },
  "AllowedHosts": "*"
like image 239
nani Avatar asked Sep 16 '25 15:09

nani


1 Answers

Try adding this to your appsettings.json:

"Kestrel": {
  "Endpoints": {
    "Https": {
      "Url": "https://*:7003",
      "Certificate": {
        "Path": "path-to-your-pfx-file.pfx",
        "Password": "password"
      }
    }
  }
}

See the docs and the ASP.NET Core source code that loads the config.

like image 110
scharnyw Avatar answered Sep 18 '25 04:09

scharnyw