Install Mkcert for SSL on Localhost

mkcert_on_local.jpg

Mkcert is a simple tool for generating locally-trusted development SSL/TLS certificates. It requires minimal configuration.

https://github.com/FiloSottile/mkcert

Prerequisites (Ubuntu / Debian)

Make sure you have:

To install on Debian (Ubuntu) use the following commands:

sudo apt install libnss3-tools

Install LinuxBrew  – get the installer

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Enable it

test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.bash_profile && echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.profile

Install mkcert

brew install mkcert;
mkcert -install;

If at this point you are getting a mkcert command not found , or Warning: /home/linuxbrew/.linuxbrew/bin is not in your PATH. you many need to fix  the global PATH var to include the mkcert bin folder. Edit your ~/$HOME/.profile file and add the following :

if [ -d "/home/linuxbrew/.linuxbrew/bin" ] ; then
    PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
fi

Save the .profile file and from the terminal run source ~/.profile

An alternative way to install Mkcert is the following (not fully tested by me): 

sudo apt-get update
sudo apt install wget libnss3-tools
set MCVER="v.1.4.1"
wget -O mkcert https://github.com/FiloSottile/mkcert/releases/download/${MCVER}/mkcert-${MCVER}-linux-amd64
chmod +x mkcert
sudo mv mkcert /user/local/bin

Why This Matters

Using mkcert lets you emulate HTTPS in your local environment, which helps with catching mixed content issues, testing secure cookies, HSTS, etc., before you deploy to production.

 


Revision #3
Created 14 June 2024 01:16:46 by peterd
Updated 13 September 2025 13:09:27 by peterd