Skip to content

Instantly share code, notes, and snippets.

@fllaca
Last active May 14, 2017 22:07
Show Gist options
  • Save fllaca/ea8472d87371196560270104d8a139b5 to your computer and use it in GitHub Desktop.
Save fllaca/ea8472d87371196560270104d8a139b5 to your computer and use it in GitHub Desktop.
SSL certificate generations
# Usage
#
# $ ./gen-cert.sh myweb
# Will generate "myweb.crt" and "myweb.key"
CERT_NAME=$1
# Generate a Private Key
openssl genrsa -des3 -out $CERT_NAME.key 1024
# Generate a CSR (Certificate Signing Request)
openssl req -new -key $CERT_NAME.key -out $CERT_NAME.csr
# Remove Passphrase from Key
cp $CERT_NAME.key $CERT_NAME.key.org
openssl rsa -in $CERT_NAME.key.org -out $CERT_NAME.key
# Generating a Self-Signed Certificate
openssl x509 -req -days 365 -in $CERT_NAME.csr -signkey $CERT_NAME.key -out $CERT_NAME.crt
echo "Generated Certificates: "
echo " - $CERT_NAME.key"
echo " - $CERT_NAME.crt"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment