Created
September 19, 2019 15:45
-
-
Save digarok/5c8e39c4edec858e80051f7d077e0904 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Self-signed certificate generator for AWS by Dagen Brock | |
# The basic instructions come from Amazon: | |
# https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/configuring-https-ssl.html | |
# | |
# Specifically, you can generate a cert with these 3 commands: | |
# openssl genrsa 2048 > privatekey.pem | |
# openssl req -new -key privatekey.pem -out csr.pem | |
# openssl x509 -req -days 365 -in csr.pem -signkey privatekey.pem -out server.crt | |
# | |
# This script walks you through generation and puts them in your specified output dir. | |
# | |
# Call the script like this: | |
# ./cert-blaster.sh mywebsite | |
# | |
# Follow the prompts and it will output your certs in `mywebsite` | |
#!/bin/bash | |
if [ "$#" -ne 1 ]; then | |
echo "Illegal number of parameters" | |
exit | |
fi | |
args=("$@") | |
DIR=${args[0]} | |
if [ -d "$DIR" ]; then | |
echo "$DIR exists. Won't overwrite. Aborting..." | |
exit 1 | |
fi | |
mkdir -p $DIR ; cd $DIR | |
PKEY=privatekey-$DIR.pem | |
CSR=csr-$DIR.pem | |
CERT=server-$DIR.crt | |
openssl genrsa 2048 > $PKEY | |
openssl req -new -key $PKEY -out $CSR | |
openssl x509 -req -days 365 -in $CSR -signkey $PKEY -out $CERT | |
cd .. | |
echo "Listing $DIR/" | |
echo "---------------" | |
ls -al $DIR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment