Skip to main content

Install Mkcert for SSL on Localhost

mkcert_on_local.jpg

MkcerttMkcert is a simple tool for makinggenerating locally-trusted development SSL/TLS certificates. It requires nominimal configuration.

https://github.com/FiloSottile/mkcert

Prerequisites (Ubuntu / Debian)

Make sure you have:

    libnss3-tools installed

    Homebrew (Linuxbrew) if you want to install via brew

    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/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.