Cancel

Install SSL/TLS certificate for localhost?

Install SSL/TLS certificate for localhost?

Prerequisites

You may need to install few packages before generating SSL/TLS certificate for localhost.

Linux (Debian, Ubuntu, Mint)

1
2
3
4
5
6
7
sudo apt install libnss3-tools linuxbrew-wrapper # pre-install for debian family

sudo wget \
  -O mkcert \
  https://github.com/FiloSottile/mkcert/releases/download/v1.4.3/mkcert-v1.4.3-linux-amd64 \
  && sudo chmod +x mkcert \
  && sudo mv mkcert /usr/local/bin

MacOSx (don’t forget to install Homebrew if you don’t have one)

1
brew install mkcert

Windows (don’t forget to install Chocolatey if you don’t have one)

1
choco install mkcert

Useful Cheatsheets

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# install the localhost Certification Authority (CA)
mkcert -install

# generate single certificate for multiple domains with wildcard
mkcert \
  -key-file key.pem \
  -cert-file cert.pem \
  local.dev "*.local.dev" myapp.dev \
  localhost 127.0.0.1 ::1

# uninstall the local CA
mkcert -uninstall

# print the location of local CA certificate
mkcert -CAROOT

Now, Install nginx? to test it.