Skip to content

Instantly share code, notes, and snippets.

@gapple
Created January 15, 2014 21:51
Show Gist options
  • Save gapple/8445457 to your computer and use it in GitHub Desktop.
Save gapple/8445457 to your computer and use it in GitHub Desktop.
Create SSL certificates signed by local root certificate. Place in /user/local/etc/apache/ssl with the root and site certs and run from that folder
#! /bin/bash
# Create a private key and certificate, signed by the local root certificate
# http://datacenteroverlords.com/2012/03/01/creating-your-own-ssl-certificate-authority/
if [ -z $1 ]
then
echo "key name is required as an argument"
exit 1
fi
# create private key
openssl genrsa -out $1.key 2048
# Create signing request
openssl req -new -key $1.key -out $1.csr
# Create certificate
openssl x509 -req -in $1.csr -CA root-ca.pem -CAkey root-ca.key -CAcreateserial -out $1.crt -days 900
# Delete the signing request since it's no longer needed
rm $1.csr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment