$linuxjunkies
>

mkcert(1)

mkcert is a simple tool for making locally-trusted development certificates with no configuration.

UbuntuDebianFedoraArch

Synopsis

mkcert [options] [domain ...]

Description

mkcert automatically creates and installs a local CA (Certificate Authority) in your system's trust store, then generates TLS certificates signed by that CA. This eliminates browser warnings for HTTPS development without complex configuration.

On first run, mkcert generates a private key and certificate for a local CA, installing it in your system's root certificate store. Subsequent runs generate domain-specific certificates signed by this local CA. It works on macOS, Linux, and Windows.

Generated certificates are saved as domain.pem (certificate) and domain-key.pem (private key) in the current directory by default.

Common options

FlagWhat it does
-installCreate and install the local CA (run this first). Creates ~/.local/share/mkcert/ on Linux.
-uninstallRemove the local CA from your system's trust store and delete the CA key.
-cert-file FILESave the certificate to a custom filename instead of domain.pem.
-key-file FILESave the private key to a custom filename instead of domain-key.pem.
-p12 FILECreate a PKCS#12 (.p12) bundle instead of separate PEM files.
-pkcs12 FILEAlias for -p12; creates a PKCS#12 bundle.
-clientGenerate a client certificate for mTLS instead of a server certificate.
-ecdsaUse ECDSA instead of RSA for the private key (smaller, faster).
-csr FILEGenerate a certificate from a Certificate Signing Request file.
-CAROOTPrint the path to the local CA root directory and exit.

Examples

Install mkcert's local CA into your system trust store. Run this once before generating certificates.

mkcert -install

Generate a certificate for example.com and www.example.com, creating example.com.pem and example.com-key.pem.

mkcert example.com www.example.com

Create a certificate for localhost and IP addresses with custom filenames.

mkcert -cert-file cert.pem -key-file key.pem localhost 127.0.0.1 ::1

Generate an ECDSA certificate for api.local with custom output filenames.

mkcert -ecdsa -cert-file server.crt -key-file server.key api.local

Create a client certificate for mutual TLS authentication.

mkcert -client -cert-file client.crt -key-file client.key

Print the CA root directory path and view the local CA certificate and key files.

echo $CAROOT && ls $CAROOT

Remove the local CA from system trust store and delete it completely.

mkcert -uninstall

Related commands