Skip to content

Instantly share code, notes, and snippets.

@wilspi
Created January 22, 2018 12:17
Show Gist options
  • Save wilspi/b607f091ef03dd362ac70860c023a753 to your computer and use it in GitHub Desktop.
Save wilspi/b607f091ef03dd362ac70860c023a753 to your computer and use it in GitHub Desktop.
Generate self signed certificates
# Provide output directory path as argument
OUTPATH=$1
# Generate CA key:
openssl genrsa -des3 -out $OUTPATH/ca.key 4096
# Generate CA certificate:
openssl req -new -x509 -days 365 -key $OUTPATH/ca.key -out $OUTPATH/ca.crt
# Generate server key:
openssl genrsa -des3 -out $OUTPATH/server.key 4096
# Generate server signing request:
openssl req -new -key $OUTPATH/server.key -out $OUTPATH/server.csr
# Self-sign server certificate:
openssl x509 -req -days 365 -in $OUTPATH/server.csr -CA $OUTPATH/ca.crt -CAkey $OUTPATH/ca.key -set_serial 01 -out $OUTPATH/server.crt
# Remove passphrase from the server key:
openssl rsa -in $OUTPATH/server.key -out $OUTPATH/server.key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment