Skip to content

Instantly share code, notes, and snippets.

@avoidik
Created October 17, 2022 12:22
Show Gist options
  • Save avoidik/39e0177de81c3d9e3ed0a6a752063b9d to your computer and use it in GitHub Desktop.
Save avoidik/39e0177de81c3d9e3ed0a6a752063b9d to your computer and use it in GitHub Desktop.
Git for Windows - Generate self-signed certificate

Newer openssl (>= 1.1.1)

MSYS_NO_PATHCONV=1 openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \
  -keyout example.key -out example.crt -subj "/CN=example.com" \
  -addext "subjectAltName=DNS:example.com,DNS:www.example.net,IP:10.0.0.1"

Before 1.1.1

MSYS_NO_PATHCONV=1 openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \
  -keyout example.key -out example.crt -extensions san -config \
  <(echo "[req]"; 
    echo distinguished_name=req; 
    echo "[san]"; 
    echo subjectAltName=DNS:example.com,DNS:www.example.net,IP:10.0.0.1
    ) \
  -subj "/CN=example.com"

Reference https://stackoverflow.com/a/41366949/7747308

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment