Skip to content

Instantly share code, notes, and snippets.

@doidor
Created July 8, 2019 08:38
Show Gist options
  • Save doidor/5a655b7a72342c5ea74ac6cdaef70444 to your computer and use it in GitHub Desktop.
Save doidor/5a655b7a72342c5ea74ac6cdaef70444 to your computer and use it in GitHub Desktop.
Simple bash script to generate a self signed SSL certificate
#!/bin/bash
if [ $# -lt 1 ]; then
echo -e "\nNeed file name as first parameter!\n\nExample:\n$ ./generate_certificate.sh server\n"
exit 0
fi
FILE_NAME="$1"
openssl genrsa -des3 -out $FILE_NAME.key 1024 &&
openssl req -new -key $FILE_NAME.key -out $FILE_NAME.csr &&
cp $FILE_NAME.key $FILE_NAME.key.org &&
openssl rsa -in $FILE_NAME.key.org -out $FILE_NAME.key &&
openssl x509 -req -days 365 -in $FILE_NAME.csr -signkey $FILE_NAME.key -out $FILE_NAME.crt &&
rm -rf $FILE_NAME.key.org $FILE_NAME.csr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment