2
2
3
3
set -Eeuo pipefail
4
4
5
- declare -i DEBUG=0
6
-
7
5
logInfo () {
8
6
echo " INFO: $@ "
9
7
}
@@ -53,10 +51,10 @@ subjectKeyIdentifier = hash
53
51
EOF
54
52
)
55
53
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}
58
56
59
- echo 01 > ${CA_SRL_FILE}
57
+ echo " 01 " > ${CA_SRL_FILE}
60
58
61
59
fi
62
60
@@ -78,8 +76,8 @@ subjectKeyIdentifier = hash
78
76
EOF
79
77
)
80
78
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
83
81
84
82
logInfo " Sign the IA request with the CA cert and key, producing the IA cert"
85
83
openssl 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 <(
95
93
) & > /dev/null
96
94
97
95
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
100
98
101
99
logInfo " Initialize the serial number for signed certificates"
102
100
echo 01 > ia.srl
@@ -108,14 +106,14 @@ openssl rsa -passin pass:foobar -in web.orig.key -out web.key &> /dev/null
108
106
logInfo " Create the signing request, using extensions"
109
107
openssl 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} " ) )
110
108
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
113
111
114
112
logInfo " Sign the request, using the intermediate cert and key"
115
113
openssl 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
116
114
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
119
117
120
118
logInfo " Concatenating fullchain.pem..."
121
119
cat web.crt ia.crt ${CA_CRT_FILE} > fullchain.pem
0 commit comments