ASP.NET Core HTTPS: Kestrel and IIS Free SSL
An ASP.NET Core app can serve HTTPS in two different places. When it runs behind IIS, IIS holds the certificate. When it runs on Kestrel alone, the app holds it. Mixing the two up is the most common reason a new site shows a browser warning or fails to start. This guide covers both paths with a free Let's Encrypt certificate, based on Microsoft's current ASP.NET Core documentation.
IIS or Kestrel: who holds the certificate
Microsoft describes two hosting models for IIS. In the in-process model the app runs inside the IIS worker process (w3wp.exe). In the out-of-process model IIS forwards requests to a Kestrel server. In-process is the default. In both cases the public HTTPS binding belongs to IIS, so you install the certificate in IIS, not in your app.
Kestrel is the server that runs the app when you start it directly, for example on Linux or in a container. There the app needs its own certificate. Microsoft's Kestrel page states that HTTPS needs a TLS certificate and that a production app needs a default certificate set explicitly. The development certificate is not installed in production.
| Setup | Where TLS ends | Certificate goes in |
|---|---|---|
| IIS, in-process | IIS | IIS server certificate store and site binding |
| IIS, out-of-process | IIS | IIS, with Kestrel on a private port |
| Kestrel only | Kestrel | appsettings.json or code |
| Reverse proxy to Kestrel | The proxy | The proxy, such as Nginx |
Option 1: IIS with a free certificate
Install the .NET Hosting Bundle first. It contains the ASP.NET Core Module that connects IIS to your app. Then get a certificate as a PFX file and bind it to the site. The full click path is in how to install free SSL on IIS. If your certificate came as PEM files, convert it with the PEM to PFX guide.
In short:
- Import the PFX into the Windows certificate store (Local Computer, Personal).
- In IIS Manager, open your site and choose Bindings.
- Add an HTTPS binding on port 443 and pick the certificate.
- Open the site by its domain name and check the padlock.
No change to the app code is needed for this path.
Option 2: Kestrel with a PFX in appsettings.json
Microsoft documents the Kestrel certificate schema for appsettings.json. A .pfx uses Path and Password. A .pem or .crt uses Path, KeyPath and Password. A certificate in the Windows store uses Subject and Store.
{
"Kestrel": {
"Endpoints": {
"Https": {
"Url": "https://*:443",
"Certificate": {
"Path": "/etc/app/site.pfx",
"Password": "set-from-secret-store"
}
}
}
}
}
Do not commit the password. Put it in an environment variable or a secret store and let configuration read it from there.
If you keep your Let's Encrypt files as PEM, point at the chain and key directly:
"Certificate": {
"Path": "/etc/letsencrypt/live/example.com/fullchain.pem",
"KeyPath": "/etc/letsencrypt/live/example.com/privkey.pem"
}
Option 3: Kestrel in code
You can also call UseHttps on a ListenOptions object. Microsoft's example loads a file and a password.
builder.WebHost.ConfigureKestrel(o =>
{
o.ListenAnyIP(443, listen =>
{
listen.UseHttps("site.pfx", pfxPassword);
});
});
Use code when you need SNI, where the server picks a certificate by host name through the ServerCertificateSelector callback. For one site, the configuration file is simpler.
Renewal
A free certificate is short-lived, so the file on disk changes. Kestrel reads the certificate when it starts, so plan a restart or a reload after each renewal. On IIS, import the new PFX and rebind it. See how to renew a Let's Encrypt certificate for the renewal side, and use acme.sh or Certbot to automate it.
Common problems
- **The app will not start after you add HTTPS.** Microsoft notes that a missing certificate makes the server fail to start. Check the file path, the password and the file permissions of the account that runs the app.
- **Browser warning on the production site.** The app is probably using the development certificate, or no default certificate is set.
- **Port 443 already in use.** IIS and a self-hosted Kestrel cannot both bind port 443 on the same address.
- **Chain errors on older clients.** Use the full chain file, not only the leaf certificate. See what an SSL certificate chain is.
Which option to pick
On a Windows server with IIS, use IIS bindings. On Linux or in a container, use a reverse proxy when you can, and Kestrel with a PEM pair when you cannot. Test the result with the free SSL checker and read about related Windows hosting in the SmarterASP.NET PFX guide.
Sources: Microsoft Learn, "Configure endpoints for the ASP.NET Core Kestrel web server" and "ASP.NET Core Module (ANCM) for IIS".
✅ Post-Installation Verification & SEO Checklist
After applying the steps above, run through this 5-point checklist to prevent browser warnings and protect your Google SEO rankings:
- Verify full CA chain trust and TLS 1.3 support using our Live SSL Checker.
- Scan for Mixed Content HTTP links and check HSTS/CSP headers on Security Headers Checker.
- Enforce a permanent 301 HTTP-to-HTTPS redirect with our HTTPS Redirect Generator.
- Confirm both root and
wwwversions resolve cleanly to one canonical HTTPS URL. - Verify your HTTPS property and
sitemap.xmlinside Google Search Console and Bing Webmaster Tools.