Guide
Self-signed SSL for localhost.
A self-signed certificate is a TLS cert you signed yourself. It is the fastest way to turn on HTTPS for local development.
What you actually need
Browsers check Subject Alternative Names, not just the common name. If you will open https://localhost, the certificate must list localhost as a DNS SAN. Add 127.0.0.1 if you use the IP.
How to generate one on SelfSignedCert
Open the self-signed SSL certificate generator. Keep the default common name localhost and the default SANs. Download the .crt and .key. Point nginx, Caddy, Next.js, or your framework at those files.
Why Chrome still warns
Self-signed is not publicly trusted. That is expected. Trust the certificate in your OS store, or create a local Root CA and issue a host certificate instead.