Skip to content

Instantly share code, notes, and snippets.



Last active Aug 7, 2016
What would you like to do?
SSL Certificate Generator (self-signed, requires openssl). Add both generated key- and crt files to your web server. Add crt to your local keychain and/or browser.
#! /bin/sh
if [ "$1" == "" ]; then
echo ""
echo "SSL Certificate Generator (self-signed, requires openssl)."
echo ""
echo " Usage:"
echo ""
echo " gencert <days> # Produces server.key and server.crt"
echo ""
exit 2
echo "Generating self-signed SSL certificate, valid for $1 days."
openssl genrsa -des3 -passout pass:x -out server.pass.key 2048
openssl rsa -passin pass:x -in server.pass.key -out server.key
openssl req -new -key server.key -out server.csr
openssl x509 -req -sha256 -days $1 -in server.csr -signkey server.key -out server.crt
rm server.pass.key server.csr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment