Luke Oliff.

TIL: Generating Trusted Local HTTPS Certs With mkcert

·TIL·1 min read·Luke Oliff

Localhost HTTPS is a pain. Self-signed certificates show browser warnings. mkcert solves both.

brew install mkcert
mkcert -install

The -install command creates a local CA certificate and trusts it in your system keychain. Your browser and curl trust this CA.

mkcert localhost 127.0.0.1 ::1

Generates a certificate for localhost, 127.0.0.1, and the IPv6 loopback. The output is two files: cert.pem and key.pem.

mkcert -key-file key.pem -cert-file cert.pem localhost 192.168.1.100

Specify custom filenames and add a LAN IP. Useful for testing on other devices on your network.

node server.js --key key.pem --cert cert.pem

Start your local server with the generated certs. No browser warnings.

Does mkcert work with Safari and Firefox?

Yes. mkcert installs the CA into the system trust store which all browsers on macOS use.

How do I revoke the CA?

mkcert -uninstall

Removes the local CA from the system trust store.