Skip to content

Instantly share code, notes, and snippets.

@danieladarve
Last active March 25, 2021 04:42
Show Gist options
  • Save danieladarve/87ef54b8fec089a0a77f20efdad1beb2 to your computer and use it in GitHub Desktop.
Save danieladarve/87ef54b8fec089a0a77f20efdad1beb2 to your computer and use it in GitHub Desktop.
SSL Certificate Template
openssl req -new -sha256 -nodes -out /opt/homebrew/etc/nginx/ssl/<your_website>.csr -newkey rsa:2048 -keyout /opt/homebrew/etc/nginx/ssl/<your_website>.key -config <(
cat <<-EOF
[req]
distinguished_name = req_distinguished_name
req_extensions = v3_req
[req_distinguished_name]
countryName = Country Name (2 letter code)
countryName_default = AU
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = Victoria
localityName = Locality Name (eg, city)
localityName_default = Melbourne
organizationalUnitName = Organizational Unit Name (eg, section)
organizationalUnitName_default = Domain Control Validated
commonName = Developer Ltd
commonName_max = 64
[ v3_req ]
# Extensions to add to a certificate request
basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = <your_website>.test
DNS.2 = *.<your_website>.test
EOF
) && echo -e "authorityKeyIdentifier=keyid,issuer\nbasicConstraints=CA:FALSE\nkeyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment\nsubjectAltName = @alt_names\n\n[alt_names]\nDNS.1 = snooze-portal.test\nDNS.2 = *.snooze-portal.test" >> snooze-portal.ext && openssl x509 -req -in <your_website>.csr -CA /opt/homebrew/etc/nginx/ssl/myCA.pem -CAkey /opt/homebrew/etc/nginx/ssl/myCA.key -CAcreateserial \
-out <your_website>.crt -days 825 -sha256 -extfile /opt/homebrew/etc/nginx/ssl/<your_website>.ext
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment