Skip to content

Commit 5bcb9d4

Browse files
committed
Generate CRLs from unit test script
1 parent b02ddde commit 5bcb9d4

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

scripts/crl-gen-openssl.test

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,33 @@ set -euo pipefail
99
# (good).
1010

1111
OPENSSL=${OPENSSL:-openssl}
12+
UNIT_TEST=${UNIT_TEST:-./scripts/unit.test}
13+
CRL_GEN_SUBTEST=${CRL_GEN_SUBTEST:-test_sk_X509_CRL_encode}
1214

1315
if ! command -v "$OPENSSL" >/dev/null 2>&1; then
1416
echo "skipping crl-gen-openssl.test: openssl not found"
1517
exit 77
1618
fi
1719

20+
if [ ! -x "$UNIT_TEST" ]; then
21+
# Fallback for out-of-tree/in-tree differences.
22+
if [ -x "./tests/unit.test" ]; then
23+
UNIT_TEST="./tests/unit.test"
24+
elif [ -x "./scripts/unit.test" ]; then
25+
UNIT_TEST="./scripts/unit.test"
26+
fi
27+
fi
28+
29+
if [ ! -x "$UNIT_TEST" ]; then
30+
echo "skipping crl-gen-openssl.test: unit.test not found"
31+
exit 77
32+
fi
33+
34+
# Run the CRL unit test to generate the CRL files and avoid race conditions
35+
# with the full unit test run.
36+
echo "Generating CRLs with: $UNIT_TEST --api -$CRL_GEN_SUBTEST"
37+
"$UNIT_TEST" --api "-$CRL_GEN_SUBTEST"
38+
1839
normalize_dn() {
1940
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' \
2041
-e 's/^issuer=//' -e 's/^subject=//' \
@@ -91,6 +112,8 @@ check_crl() {
91112
fi
92113

93114
local verify_out verify_rc verify_out_norm
115+
# Capture both stdout and stderr so we can reliably detect and print the
116+
# revocation text.
94117
verify_out=$("$OPENSSL" verify -CAfile "$ca_cert" -crl_check \
95118
-CRLfile "$crl" \
96119
"$revoked_cert" 2>&1) || verify_rc=$?
@@ -109,7 +132,7 @@ check_crl() {
109132

110133
if [ -n "$good_cert" ]; then
111134
if ! "$OPENSSL" verify -CAfile "$ca_cert" -crl_check -CRLfile "$crl" \
112-
"$good_cert" >/dev/null 2>&1; then
135+
"$good_cert" >/dev/null; then
113136
echo "expected successful verification for $label CRL with " \
114137
"$good_cert"
115138
return 1

0 commit comments

Comments
 (0)