Last active
October 8, 2016 18:52
-
-
Save nathanborror/df6491debd1c86e40eb737751523350a to your computer and use it in GitHub Desktop.
This file contains 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 | |
# | |
# Generate RSA certificate and key | |
# | |
# The 'host' is the host on which the server is listening and 'prefix' is just | |
# used to prefix the output files. | |
# | |
# $ gen.sh <host> <prefix> | |
# | |
PASSWORD=`LC_CTYPE=C tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 32 | head -n 1` | |
HOST=$1 | |
if [ -z $HOST ]; then HOST="localhost"; fi | |
PREFIX=$2 | |
if [ -z $PREFIX ]; then PREFIX="dev"; fi | |
openssl genrsa -passout pass:${PASSWORD} -des3 -out "${PREFIX}_server.key" 4096 | |
openssl req -passin pass:${PASSWORD} -new -x509 -days 3650 -key "${PREFIX}_server.key" -out "${PREFIX}_server.crt" -subj '/C=US/ST=CA/L=PaloAlto/O=MyApp/CN='${HOST}'/emailAddress=nathan@nathanborror.com' | |
openssl rsa -passin pass:${PASSWORD} -in "${PREFIX}_server.key" -out "${PREFIX}_server.key" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment