Created
July 8, 2019 08:38
-
-
Save doidor/5a655b7a72342c5ea74ac6cdaef70444 to your computer and use it in GitHub Desktop.
Simple bash script to generate a self signed SSL certificate
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 | |
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