From 27bdbd25a33d65fe0211cba82359afcd6395fdf9 Mon Sep 17 00:00:00 2001 From: Someone Date: Thu, 5 Feb 2015 00:55:40 +0100 Subject: [PATCH] Some clarification and fixes. --- certgen.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/certgen.sh b/certgen.sh index ad0095b..b7dc932 100755 --- a/certgen.sh +++ b/certgen.sh @@ -1,7 +1,6 @@ #!/bin/bash MYPWD=$(pwd) -export CA_PATH="$MYPWD/ca/" umask 0027 echo "cleanup previous run..." @@ -32,13 +31,14 @@ while read cdline ; do mkdir -m 0700 certs crl newcerts touch index.txt export CA_PATH="./" - openssl req -batch -new -newkey rsa:4096 -keyout ca.key -out ca.csr -nodes -subj "${certdata[2]}" -reqexts v3_ca_req -config "${MYPWD}/openssl.cnf" + openssl req -batch -new -newkey rsa:4096 -keyout ca.key -out ca.csr -nodes -subj "${certdata[2]}" -reqexts v3_ca_req -config "${MYPWD}/openssl.cnf" &>/dev/null openssl ca -batch -create_serial -out ca.crt -days 3650 -keyfile ca.key -selfsign -extensions v3_ca -config "${MYPWD}/openssl.cnf" -infiles ca.csr continue fi # Handle non "CA" types here. + export CA_PATH="$MYPWD/ca/" SUBJECT="${certdata[2]}CN=${certdata[1]}/" DNS_NAMES="${certdata[1]},${certdata[3]}" OLDIFS=$IFS @@ -62,13 +62,14 @@ while read cdline ; do if [[ ${certdata[0]} == "SGN" ]] ; then if [[ ! -d "${CA_PATH}" ]] ; then echo "*** ERROR - NO CA DATA FOUND ***" 1>&2 - echo "*** maybe generate a CA and move it to ca first ***" 1>&2 - echo "copy template: mv output/SomeNet ca" 1>&2 + echo "*** maybe generate a CA and move it to ${CA_PATH} ***" 1>&2 + echo "copy template: mv output/SomeNet ${CA_PATH}" 1>&2 echo "*** ABORTED ***" 1>&2 exit 2 fi - openssl ca -batch -create_serial -out "${certdata[1]}.crt" -days 365 -keyfile "${MYPWD}/ca/ca.key" -extensions v3_ca -config "${MYPWD}/openssl.cnf" -infiles "${certdata[1]}.csr" + openssl ca -batch -create_serial -out "${certdata[1]}.crt" -days 365 -keyfile "${MYPWD}/ca/ca.key" -extensions v3_ca \ + -config "${MYPWD}/openssl.cnf" -infiles "${certdata[1]}.csr" cat "${MYPWD}/ca/ca.crt" >> "${certdata[1]}.crt" elif [[ ${certdata[0]} == "CRT" ]] ; then -- 2.43.0