From: Someone Date: Wed, 12 Apr 2023 21:50:34 +0000 (+0200) Subject: feature request by strudl: handle ip addresses X-Git-Url: https://git.somenet.org/somenet/certgen.git/commitdiff_plain?ds=inline feature request by strudl: handle ip addresses --- 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