Skip to content

Instantly share code, notes, and snippets.

@robbiet480
Created September 28, 2013 19:04
Show Gist options
  • Save robbiet480/6745307 to your computer and use it in GitHub Desktop.
Save robbiet480/6745307 to your computer and use it in GitHub Desktop.
script to generate certificates from your own certificate authority
#!/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