Last active
June 13, 2017 18:30
-
-
Save guimaluf/392cf07cf9f8f7241da993b3c9e1e9ab to your computer and use it in GitHub Desktop.
Simple bash script for generating self-signed certificates with wildcard
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 | |
function usage { | |
echo "usage: $0 hostname" | |
exit 0 | |
} | |
HOSTNAME=$1 | |
[ -z ${HOSTNAME} ] && usage | |
SERVER_KEY=${HOSTNAME}.key | |
SERVER_CERT=${HOSTNAME}.crt | |
DAYS=$((365*10)) | |
SUBJECT="/C=BR/ST=RN/L=Natal/O=Anolis/CN=${HOSTNAME}" | |
openssl req -new -newkey rsa:2048 -nodes -x509 -sha256 \ | |
-days ${DAYS} \ | |
-subj "${SUBJECT}" \ | |
-keyout ${SERVER_KEY} \ | |
-reqexts SAN -extensions SAN \ | |
-config <(cat /etc/ssl/openssl.cnf <(printf "[SAN]\nsubjectAltName=DNS:*.${HOSTNAME}")) \ | |
-out ${SERVER_CERT} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment