Skip to content

Instantly share code, notes, and snippets.

@oprietop
Last active November 29, 2017 11:39
Show Gist options
  • Save oprietop/842d38987416461f97531d10e2f28775 to your computer and use it in GitHub Desktop.
Save oprietop/842d38987416461f97531d10e2f28775 to your computer and use it in GitHub Desktop.
Bourne Shell script to create self-signed certs
#!/bin/sh
# We can set our CN using it as an argument
[ -n "$1" ] && CN=$1 || CN=localhost
# RSA params
RSA=2048
DAYS=365
# subj Params
C=HU
ST=Latveria
L=Doomstadt
O=CastleDoom
OU=IT
emailAdress=admin@localhost.localdomain
# Do It
openssl req -new -newkey rsa:$RSA -days $DAYS -nodes -x509 \
-subj "/C=$C/ST=$ST/L=$CN/O=$O/OU=$OU/CN=$CN/emailAddress=$emailAdress" \
-keyout $CN.key -out $CN.cert > /dev/null 2>&1
# Print the certs
echo "# $CN.key"
cat $CN.key
echo "# $CN.cert"
cat $CN.cert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment