Last active
December 12, 2016 06:11
-
-
Save webee/8c4d9a5359b88bd23c72a25c5cd2f1b5 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
#!/bin/bash | |
# /etc/nginx/ssl/<site>/ | |
site=$1 | |
# DNS:www.abc.xyz,DNS:xyz.abc.xyz | |
domains=$2 | |
OPENSSL_CNF=/etc/pki/tls/openssl.cnf | |
ssl_dir=/etc/nginx/ssl | |
mkdir -p ${ssl_dir} | |
cd ${ssl_dir} | |
! [ -f account.key ] && openssl genrsa 4096 > account.key | |
! [ -f domain.key ] && openssl genrsa 4096 > domain.key | |
mkdir -p ${site} | |
if ! [ -f "${site}/domain.csr" ]; then | |
openssl req -new -sha256 -key domain.key -subj "/" -reqexts SAN -config <(cat ${OPENSSL_CNF} <(printf "[SAN]\nsubjectAltName=${domains}")) > ${site}/domain.csr | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment