-
-
Save jmcabandara/140b70e203485d0f6eab390e2d8cf95a to your computer and use it in GitHub Desktop.
Generate a self signed cert (spits out an ssl.key and ssl.cert) in one go
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
#!/bin/bash | |
# Easily generate a 10 year SSL certificate and key for development. It | |
# creates a configuration file for wild card domains, if no argument is passed | |
# in will fallback to "node.a" as the domain to use. | |
# | |
# Upon completion, these files should now exist:: | |
# | |
# * openssl.cnf | |
# * ssl.key | |
# * ssl.crt | |
# | |
# If those files exist they will be overwritten | |
set -e | |
if [ ! -z $1 ] | |
then | |
domain=$1 | |
else | |
domain="node.a" | |
fi | |
template="[req] | |
distinguished_name = req_distinguished_name | |
x509_extensions = v3_req | |
prompt = no | |
[req_distinguished_name] | |
CN = *.${domain} | |
[v3_req] | |
keyUsage = keyEncipherment, dataEncipherment | |
extendedKeyUsage = serverAuth | |
subjectAltName = @alt_names | |
[alt_names] | |
DNS.1 = *.${domain}" | |
echo "-> generating openssl.cnf configuration file" | |
echo "$template" > openssl.cnf | |
command="openssl req -new -newkey rsa:2048 -sha1 -days 3650 -nodes -x509 -keyout ssl.key -out ssl.crt -config openssl.cnf" | |
echo "-> running: $command" | |
openssl req -new -newkey rsa:2048 -sha1 -days 3650 -nodes -x509 -keyout ssl.key -out ssl.crt -config openssl.cnf | |
echo "-> completed self signed certs" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment