Skip to content

Instantly share code, notes, and snippets.

@134130
Created February 22, 2024 10:18
Show Gist options
  • Save 134130/829740c9701f24e64fcfa9dce27b040a to your computer and use it in GitHub Desktop.
Save 134130/829740c9701f24e64fcfa9dce27b040a to your computer and use it in GitHub Desktop.
Simple openssl command creating x509 certificate with CA chain
#!/bin/sh
cat > req.conf <<EOF
[req]
prompt = no
x509_extensions = v3_req
distinguished_name = dn
[dn]
CN = querypie
[v3_req]
subjectAltName = @alt_names
[alt_names]
DNS.1 = ${dns_name}
EOF
openssl req -new -x509 -nodes \
-newkey rsa:4096 -keyout rootCA.key \
-passout "pass:$(openssl rand -base64 32)" \
-config req.conf \
-days 3650 \
-out rootCA.crt
openssl req -new -x509 \
-newkey rsa:4096 -keyout server.key \
-CA rootCA.crt \
-CAkey rootCA.key \
-config req.conf \
-passout "pass:$(openssl rand -base64 32)" \
-days 3650 \
-out server.crt
rm req.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment