changeset 26:86ca8ee7b597

Add an option for an alternate domain name Required for mail.ibboard.co.uk to also run as mx.ibboard.co.uk
author IBBoard <dev@ibboard.co.uk>
date Sat, 07 Mar 2020 16:36:24 +0000
parents b9e808b6b01e
children c7621908cb47
files make-certificate
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/make-certificate	Fri Jul 26 19:52:55 2019 +0100
+++ b/make-certificate	Sat Mar 07 16:36:24 2020 +0000
@@ -2,8 +2,8 @@
 
 set -e
 
-if [ $# -ne 1 ]; then
-	echo "Usage: $0 <key-name>"
+if [ $# -ne 1 -a $# -ne 2 ]; then
+	echo "Usage: $0 <key-name> [<alt-name>]"
 	exit 1
 fi
 
@@ -12,10 +12,16 @@
 	exit 1
 fi
 
+if [ $# -eq 2 ]; then
+	extra="\nDNS.2=$2"
+else
+	extra=""
+fi
+
 pushd ~/Websites/certs/
 
 openssl req -nodes -sha256 -new -keyout $1.key -out $1.csr -subj "/C=GB/ST=Worcestershire/O=$1/CN=$1" \
-	-config <(cat ~/.ssh/CA/openssl.cnf <(echo "DNS.1=$1"))
+	-config <(cat ~/.ssh/CA/openssl.cnf <(echo -e "DNS.1=${1}${extra}"))
 openssl ca -in $1.csr -out $1.crt -cert ~/.ssh/CA/ca.crt -keyfile ~/.ssh/CA/ca.key -days 365 \
-	-config <(cat ~/.ssh/CA/openssl.cnf <(echo "DNS.1=$1")) -batch
+	-config <(cat ~/.ssh/CA/openssl.cnf <(echo -e "DNS.1=${1}${extra}")) -batch
 popd