6 echo "cleanup previous run..."
8 mkdir output/csr output/crt
10 while read cdline ; do
11 if [[ $cdline == "" || $cdline == "#"* ]] ; then
16 read -a certdata <<< "$cdline"
18 echo "*** Processing: $(date -Iseconds) - ${certdata[0]} - ${certdata[1]} ***"
19 if [[ -d "output/${certdata[1]}" ]] ; then
20 echo "*** ERROR - THIS SEEMS TO ALREADY EXIST ***" 1>&2
21 echo "*** ABORTED ***" 1>&2
25 mkdir "output/${certdata[1]}"
26 chmod o+x "output/${certdata[1]}"
28 SUBJECT="${certdata[2]}CN=${certdata[1]}/"
29 DNS_NAMES="${certdata[1]},${certdata[3]}"
32 cat openssl.cnf > /tmp/certgen.cnf
34 for name in $DNS_NAMES; do
35 COUNTER=$((COUNTER+1))
36 echo "DNS.${COUNTER} = $name" >> /tmp/certgen.cnf
42 cd "output/${certdata[1]}"
43 openssl genrsa -out "${certdata[1]}.key" 4096 &> /dev/null
44 openssl req -new -key "${certdata[1]}.key" -out "${certdata[1]}.csr" -utf8 -batch -subj "${SUBJECT}" -config /tmp/certgen.cnf
46 if [[ ${certdata[0]} == "CRT" ]] ; then
47 openssl x509 -req -signkey "${certdata[1]}.key" -in "${certdata[1]}.csr" -out "${certdata[1]}.crt" -extensions v3_req -extfile /tmp/certgen.cnf \
48 -days 365 -sha512 &> /dev/null
49 chmod o+r "${certdata[1]}.crt"
51 echo -n "${certdata[1]} " >> "${MYPWD}/output/fpfile.txt"
52 openssl x509 -in "${certdata[1]}.crt" -fingerprint -noout -sha512 >> "${MYPWD}/output/fpfile.txt"
53 echo "" >> "${MYPWD}/output/fpfile.txt"
59 if [[ ${certdata[0]} == "CRT" ]] ; then
60 mv "output/${certdata[1]}" "output/crt/${certdata[1]}"
62 mv "output/${certdata[1]}" "output/csr/${certdata[1]}"
68 ls -l output/*/ | grep -v "total"