Last active
March 27, 2018 19:48
-
-
Save cvarjao/7860151133665aff3135dbcfa149c993 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env bash | |
# bash <(curl -sL https://gist.githubusercontent.com/cvarjao/7860151133665aff3135dbcfa149c993/raw/) | |
CN="$1" | |
CN_FILE_NAME="${CN//[.]/_}" | |
echo "CN=${CN}" | |
echo "CN_FILE_NAME=${CN_FILE_NAME}" | |
set -x | |
rm -f "${CN_FILE_NAME}.passphrase" | |
rm -f "${CN_FILE_NAME}.key" | |
rm -f "${CN_FILE_NAME}.csr" | |
rm -f "${CN_FILE_NAME}.crt" | |
openssl rand -base64 48 > "${CN_FILE_NAME}.passphrase" | |
openssl genrsa -aes128 -passout "file:${CN_FILE_NAME}.passphrase" -out "${CN_FILE_NAME}._key" 2777 | |
openssl req -new -passin "file:${CN_FILE_NAME}.passphrase" -key "${CN_FILE_NAME}._key" -out "${CN_FILE_NAME}.csr" -subj "/C=CA/ST=British Columbia/L=Victoria/O=Government of the Province of British Columbia/OU=FLNRORD/CN=${CN}" | |
openssl rsa -in "${CN_FILE_NAME}._key" -passin "file:${CN_FILE_NAME}.passphrase" -out "${CN_FILE_NAME}.key" | |
openssl x509 -req -days 36500 -in "${CN_FILE_NAME}.csr" -signkey "${CN_FILE_NAME}.key" -out "${CN_FILE_NAME}.crt" | |
rm -f "${CN_FILE_NAME}._key" | |
rm -f "${CN_FILE_NAME}.passphrase" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment