22
33set -Eeuo pipefail
44
5- declare -i DEBUG=0
6-
75logInfo () {
86 echo " INFO: $@ "
97}
@@ -53,10 +51,10 @@ subjectKeyIdentifier = hash
5351EOF
5452)
5553
56- [[ ${DEBUG} -gt 0 ] ] && logInfo " show the CA cert details"
57- [[ ${DEBUG} -gt 0 ] ] && openssl x509 -noout -text -in ${CA_CRT_FILE}
54+ [ " ${DEBUG_CA_CERT} " = " true " ] && logInfo " show the CA cert details"
55+ [ " ${DEBUG_CA_CERT} " = " true " ] && openssl x509 -noout -text -in ${CA_CRT_FILE}
5856
59- echo 01 > ${CA_SRL_FILE}
57+ echo " 01 " > ${CA_SRL_FILE}
6058
6159fi
6260
@@ -78,8 +76,8 @@ subjectKeyIdentifier = hash
7876EOF
7977)
8078
81- [[ ${DEBUG} -gt 0 ] ] && logInfo " Show the singing request, to make sure extensions are there"
82- [[ ${DEBUG} -gt 0 ] ] && openssl req -in ia.csr -noout -text
79+ [ " ${DEBUG_CA_CERT} " = " true " ] && logInfo " Show the singing request, to make sure extensions are there"
80+ [ " ${DEBUG_CA_CERT} " = " true " ] && openssl req -in ia.csr -noout -text
8381
8482logInfo " Sign the IA request with the CA cert and key, producing the IA cert"
8583openssl x509 -req -days 730 -in ia.csr -CA ${CA_CRT_FILE} -CAkey ${CA_KEY_FILE} -CAserial ${CA_SRL_FILE} -out ia.crt -passin pass:foobar -extensions IA -extfile <(
9593) & > /dev/null
9694
9795
98- [[ ${DEBUG} -gt 0 ] ] && logInfo " show the IA cert details"
99- [[ ${DEBUG} -gt 0 ] ] && openssl x509 -noout -text -in ia.crt
96+ [ " ${DEBUG_CA_CERT} " = " true " ] && logInfo " show the IA cert details"
97+ [ " ${DEBUG_CA_CERT} " = " true " ] && openssl x509 -noout -text -in ia.crt
10098
10199logInfo " Initialize the serial number for signed certificates"
102100echo 01 > ia.srl
@@ -108,14 +106,14 @@ openssl rsa -passin pass:foobar -in web.orig.key -out web.key &> /dev/null
108106logInfo " Create the signing request, using extensions"
109107openssl req -new -key web.key -sha256 -out web.csr -passin pass:foobar -subj " /C=NL/ST=Noord Holland/L=Amsterdam/O=ME/OU=IT/CN=${CN_WEB} " -reqexts SAN -config <( cat <( printf " [req]\ndistinguished_name = dn\n[dn]\n[SAN]\nsubjectAltName=${ALLDOMAINS} " ) )
110108
111- [[ ${DEBUG} -gt 0 ] ] && logInfo " Show the singing request, to make sure extensions are there"
112- [[ ${DEBUG} -gt 0 ] ] && openssl req -in web.csr -noout -text
109+ [ " ${DEBUG_CA_CERT} " = " true " ] && logInfo " Show the singing request, to make sure extensions are there"
110+ [ " ${DEBUG_CA_CERT} " = " true " ] && openssl req -in web.csr -noout -text
113111
114112logInfo " Sign the request, using the intermediate cert and key"
115113openssl x509 -req -days 365 -in web.csr -CA ia.crt -CAkey ia.key -out web.crt -passin pass:foobar -extensions SAN -extfile <( cat <( printf " [req]\ndistinguished_name = dn\n[dn]\n[SAN]\nsubjectAltName=${ALLDOMAINS} " ) ) & > /dev/null
116114
117- [[ ${DEBUG} -gt 0 ] ] && logInfo " Show the final cert details"
118- [[ ${DEBUG} -gt 0 ] ] && openssl x509 -noout -text -in web.crt
115+ [ " ${DEBUG_CA_CERT} " = " true " ] && logInfo " Show the final cert details"
116+ [ " ${DEBUG_CA_CERT} " = " true " ] && openssl x509 -noout -text -in web.crt
119117
120118logInfo " Concatenating fullchain.pem..."
121119cat web.crt ia.crt ${CA_CRT_FILE} > fullchain.pem
0 commit comments