Created
October 30, 2016 08:06
-
-
Save renier/f54eed9f8e25f3ae1a71ee6449008ef8 to your computer and use it in GitHub Desktop.
Generate an SSL certificate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DOMAIN=$(hostname -f) | |
export PASSPHRASE=$(head -c 500 /dev/urandom | tr -dc a-z0-9A-Z | head -c 128; echo) | |
subj=" | |
C=$1 | |
ST=$2 | |
O=$3 | |
localityName=$4 | |
commonName=$DOMAIN | |
organizationalUnitName=$5 | |
emailAddress=$6 | |
" | |
openssl genrsa -des3 -out cert.key -passout env:PASSPHRASE 2048 | |
openssl req \ | |
-new \ | |
-batch \ | |
-subj "$(echo -n "$subj" | tr "\n" "/")" \ | |
-key cert.key \ | |
-out cert.csr \ | |
-passin env:PASSPHRASE | |
cp cert.key cert.key.orig | |
openssl rsa -in cert.key.orig -out cert.key -passin env:PASSPHRASE | |
openssl x509 -req -days 3650 -in cert.csr -signkey cert.key -out cert.crt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment