auto create ssl - 1990bingliu/https_create GitHub Wiki
#! /bin/bash
buildPath=$(cd `dirname $0`; pwd)
#configPath=/etc/ssl/openssl.cnf
configPath=${buildPath}/conf/openssl.cnf
caPath=${buildPath}/ca
distPath=${buildPath}/dist
echo "Please input domain name(eg. your.local)"
read -p "Domain Name:" domainName
# add New domain Name into SAN
sudo sed -i "s/^DNS\.6.*$/DNS.6 = ${domainName}/g" ${configPath}
sudo sed -i "s/^DNS\.7.*$/DNS.7 = ${domainName}\*/g" ${configPath}
openssl genrsa -out ${distPath}/${domainName}.key
openssl req -new -key ${distPath}/${domainName}.key -out ${distPath}/${domainName}.csr
openssl ca -in ${distPath}/${domainName}.csr -md sha256 -days 3650 -out ${distPath}/${domainName}.crt -cert ${caPath}/ca.crt -keyfile ${caPath}/ca.key -extensions v3_req -config ${configPath}
openssl x509 -text -noout -in ${distPath}/${domainName}.crt