Skip to content

Instantly share code, notes, and snippets.

@sjoorm
Forked from jessedearing/gist:2351836
Last active August 29, 2015 14:01
Show Gist options
  • Save sjoorm/4f6ff7d7bc3f61fc90b0 to your computer and use it in GitHub Desktop.
Save sjoorm/4f6ff7d7bc3f61fc90b0 to your computer and use it in GitHub Desktop.
SSL certificate generator
#!/bin/bash
name=
if [ -z "$1" ]
then
name=cert
else
name=$1
fi
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -aes-256-cbc -out $name.key 2048
echo "Generating a Certificate Signing Request..."
openssl req -new -key $name.key -out $name.csr
echo "Removing passphrase from key (for nginx)..."
cp $name.key $name.key.org
openssl rsa -in $name.key.org -out $name.key
rm $name.key.org
echo "Generating certificate..."
openssl x509 -req -days 365 -in $name.csr -signkey $name.key -out $name.crt
#echo "Copying certificate ($name) to /etc/nginx/ssl/"
#mkdir -p /etc/nginx/ssl
#cp $name.crt /etc/nginx/ssl/
#echo "Copying key (myssl.key) to /etc/nginx/ssl/"
#mkdir -p /etc/nginx/ssl
#cp $name.key /etc/nginx/ssl/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment