From ad66c39ad2b618c6c1dd7ce6701483ac5c897fa0 Mon Sep 17 00:00:00 2001 From: Someone Date: Wed, 12 Apr 2023 23:50:34 +0200 Subject: [PATCH] feature request by strudl: handle ip addresses --- certgen.data.example | 8 ++++---- certgen.sh | 11 ++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/certgen.data.example b/certgen.data.example index bfe4a19..42289dc 100644 --- a/certgen.data.example +++ b/certgen.data.example @@ -5,18 +5,18 @@ # Format: # EXIT # CA -# SGN +# SGN # This will create a cert and sign with the ca located in ./ca/ -# CRT +# CRT # This will create a self signed cert. -# CSR +# CSR # This will create a cert request only. # # For some strange reason the subject line has to start with /emailAddress=... # Otherwise some weird stuff happens - good job, openssl folks :/ # For failing services ;) -CRT localhost /emailAddress=root@localhost/OU=CertGen/O=YouFailed;)/ *.loc,loc,l,*.l +CRT localhost /emailAddress=root@localhost/OU=CertGen/O=YouFailed;)/ *.loc,loc,l,*.l 127.0.0.1,127.0.1.1 # stop certgen here EXIT 0 Stop processing here - comment out or delete. diff --git a/certgen.sh b/certgen.sh index c15ea89..1003300 100755 --- a/certgen.sh +++ b/certgen.sh @@ -5,7 +5,7 @@ umask 0027 echo "cleanup previous run..." rm -rf output/* -mkdir output/csr output/crt output/sgn +mkdir -p output/csr output/crt output/sgn while read cdline ; do if [[ $cdline == "" || $cdline == "#"* ]] ; then @@ -46,6 +46,7 @@ while read cdline ; do export CA_PATH="$MYPWD/ca/" SUBJECT="$(echo -n "${certdata[2]}" | sed -e 's/_/ /g')CN=${certdata[1]}/" DNS_NAMES="${certdata[1]},${certdata[3]}" + IPS="${certdata[4]}" OLDIFS=$IFS IFS="," cat "${MYPWD}/openssl.cnf" > /tmp/certgen.cnf @@ -57,6 +58,14 @@ while read cdline ; do COUNTER=$((COUNTER+1)) echo "DNS.${COUNTER} = $name" >> /tmp/certgen.cnf done + COUNTER=0 + for ip in $IPS; do + if [[ "" == $ip ]] ; then + continue + fi + COUNTER=$((COUNTER+1)) + echo "IP.${COUNTER} = $ip" >> /tmp/certgen.cnf + done IFS=$OLDIFS unset OLDIFS unset COUNTER -- 2.43.0