Skip to content

Commit 487315e

Browse files
committed
Cleanup: Add debugging mode for creating CA certificates
1 parent b115f70 commit 487315e

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,15 @@ ENV REGISTRIES="docker.caching.proxy.internal registry-1.docker.io auth.docker.i
6666
ENV AUTH_REGISTRIES=""
6767
# Should we verify upstream's certificates? Default to true.
6868
ENV VERIFY_SSL="true"
69+
6970
# Enable debugging mode; this inserts mitmproxy/mitmweb between the CONNECT proxy and the caching layer
7071
ENV DEBUG="false"
7172
# Enable debugging mode; this inserts mitmproxy/mitmweb between the caching layer and DockerHub's registry
7273
ENV DEBUG_HUB="false"
7374
# Enable nginx debugging mode; this uses nginx-debug binary and enabled debug logging, which is VERY verbose so separate setting
7475
ENV DEBUG_NGINX="false"
76+
# Enable debugging mode for creating CA certificate
77+
ENV DEBUG_CA_CERT="false"
7578

7679
# Set Docker Registry cache size, by default, 32 GB ('32g')
7780
ENV CACHE_MAX_SIZE="32g"

create_ca_cert.sh

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
set -Eeuo pipefail
44

5-
declare -i DEBUG=0
6-
75
logInfo() {
86
echo "INFO: $@"
97
}
@@ -53,10 +51,10 @@ subjectKeyIdentifier = hash
5351
EOF
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

6159
fi
6260

@@ -78,8 +76,8 @@ subjectKeyIdentifier = hash
7876
EOF
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

8482
logInfo "Sign the IA request with the CA cert and key, producing the IA cert"
8583
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,8 +93,8 @@ EOF
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

10199
logInfo "Initialize the serial number for signed certificates"
102100
echo 01 > ia.srl
@@ -108,14 +106,14 @@ openssl rsa -passin pass:foobar -in web.orig.key -out web.key &> /dev/null
108106
logInfo "Create the signing request, using extensions"
109107
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}"))
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

114112
logInfo "Sign the request, using the intermediate cert and key"
115113
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
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

120118
logInfo "Concatenating fullchain.pem..."
121119
cat web.crt ia.crt ${CA_CRT_FILE} > fullchain.pem

0 commit comments

Comments
 (0)