Created
April 11, 2016 12:42
-
-
Save jdforsythe/6928ff0c8f2e2d79e3a2ce02fb2a9364 to your computer and use it in GitHub Desktop.
Create Certificate Authority
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 | |
# generate root CA key | |
echo "Generating root CA key" | |
openssl genrsa -aes256 -out rootca.key 2048 | |
# generate root CA certificate (20 years) | |
echo "Generating root CA certificate" | |
openssl req -new -x509 -key rootca.key -days 7304 -sha256 | |
echo "Finished." |
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="$1" | |
# create client key | |
echo "Generating client key ${DOMAIN}.key" | |
openssl genrsa -aes256 -out "${DOMAIN}.key" 2048 | |
# use key to generate certificate signing request | |
echo "Generating certificate signing request ${DOMAIN}.req" | |
openssl req -new -key "${DOMAIN}.key" -out "${DOMAIN}.req" | |
# sign the request with the CA key/cert to generate a signed certificate | |
echo "Generating signed certificate ${DOMAIN}.cer" | |
CASERIAL=rootca.srl | |
if [ -f $CASERIAL ]; then | |
openssl x509 -req -in "${DOMAIN}.req" -out "${DOMAIN}.cer" -CA rootca.cer -CAkey rootca.key | |
else | |
openssl x509 -req -in "${DOMAIN}.req" -out "${DOMAIN}.cer" -CA rootca.cer -CAkey rootca.key -CAcreateserial | |
fi | |
echo "Finished." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment