Created
September 28, 2013 19:04
-
-
Save robbiet480/6745307 to your computer and use it in GitHub Desktop.
script to generate certificates from your own 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 | |
if [ "$#" == "0" ]; then | |
echo "Please enter the domain name: " | |
read sslhost | |
else | |
sslhost=$1 | |
fi | |
mkdir output/$sslhost | |
openssl req -config openssl.my.cnf -new -nodes -keyout output/$sslhost/$sslhost.key -out output/$sslhost/$sslhost.csr -days 365 -subj "/C=US/ST=California/L=Oakland/CN=$sslhost" | |
openssl ca -config openssl.my.cnf -policy policy_anything -out output/$sslhost/$sslhost.crt -infiles output/$sslhost/$sslhost.csr | |
read -p "Copy to /etc/nginx/ssl/? (needs sudo) " -n 1 -r | |
echo # (optional) move to a new line | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
sudo cp $output/$sslhost/$sslhost.{key,crt} /etc/nginx/ssl/ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment