Security and certificates

Make a self-signed certificate with OpenSSL

Create a certificate and key for testing HTTPS, in one command.

Fill these in once
  1. Make the certificate and key
    Terminal
    openssl req -x509 -newkey rsa:4096 -sha256 -days 365 -nodes -keyout server.key -out server.crt -subj "/CN=localhost" -addext "subjectAltName=DNS:localhost"

    Browsers will warn about it. For trusted local HTTPS, use mkcert instead.

Check it worked

  1. Check what's in it
    Terminal
    openssl x509 -in server.crt -noout -subject -dates
  1. Make the certificate and key
    Terminal · Ubuntu / Debian
    openssl req -x509 -newkey rsa:4096 -sha256 -days 365 -nodes -keyout server.key -out server.crt -subj "/CN=localhost" -addext "subjectAltName=DNS:localhost"

    Browsers will warn about it. For trusted local HTTPS, use mkcert instead.

Check it worked

  1. Check what's in it
    Terminal · Ubuntu / Debian
    openssl x509 -in server.crt -noout -subject -dates
  1. Make the certificate and key (OpenSSL comes with Git for Windows)
    PowerShell
    & "C:\Program Files\Git\usr\bin\openssl.exe" req -x509 -newkey rsa:4096 -sha256 -days 365 -nodes -keyout server.key -out server.crt -subj "/CN=localhost" -addext "subjectAltName=DNS:localhost"

    Browsers will warn about it. For trusted local HTTPS, use mkcert instead.

Check it worked

  1. Check what's in it
    PowerShell
    & "C:\Program Files\Git\usr\bin\openssl.exe" x509 -in server.crt -noout -subject -dates