tzafarpk
4/14/2020 - 4:19 PM

Enable HTTPS on the local docker environment

Enable HTTPS on the local docker environment

Windows Environment Setup

Install Chocolatey

Source: https://chocolatey.org/install

  1. Run PowerShell as administrator

  2. Run Get-ExecutionPolicy. If it returns Restricted, then run Set-ExecutionPolicy AllSigned or Set-ExecutionPolicy Bypass -Scope Process

  3. Run the following command to install Chocolatey

    Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
    

Install and setup certificates

Source: https://github.com/FiloSottile/mkcert

# search package
$ choco search mkcert
# list installed packages
$ choco list --local-only
# install mkcert package
$ choco install mkcert
# install a local CA (Certificate Authority)
$ mkcert -install
# create a new certificate valid for the following names
$ mkcert "*.tphp.net" "*.trafficdemos.net" "*.futuristic.agency" localhost 127.0.0.1 ::1

Install and use in Linux

# first install `certutil`
sudo apt-get update
sudo apt install libnss3-tools
# goto releases, copy `amd64` release and download
wget -O mkcert https://github.com/FiloSottile/mkcert/releases/download/v1.4.4/mkcert-v1.4.4-linux-amd64
# make the file executable and place the binary under `/usr/local/bin`
chmod +x mkcert
sudo mv mkcert /usr/local/bin
# install the local CA (Certificate Authority) in the system trust store
mkcert -install
# create a new certificate valid for the following names
mkcert example.com "*.aecb.gov.ae" localhost 127.0.0.1 ::1
# update-ca-certificates is a program that updates the directory /etc/ssl/certs
# to hold SSL certificates and generates ca-certificates
update-ca-certificates