Skip to content

Commit 6452ec9

Browse files
authored
Merge pull request #2589 from dcooper16/sha256_stapled_ocsp
Accept stapled OCSP responses that use SHA-256 in CertID
2 parents b2e6f99 + 1f37a84 commit 6452ec9

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

testssl.sh

+17-5
Original file line numberDiff line numberDiff line change
@@ -2035,7 +2035,7 @@ check_revocation_ocsp() {
20352035
local stapled_response="$2"
20362036
local jsonID="$3"
20372037
local tmpfile=""
2038-
local -i success
2038+
local -i success=1
20392039
local response=""
20402040
local host_header=""
20412041

@@ -2052,9 +2052,20 @@ check_revocation_ocsp() {
20522052
tmpfile=$TEMPDIR/${NODE}-${NODEIP}.${uri##*\/} || exit $ERR_FCREATE
20532053
if [[ -n "$stapled_response" ]]; then
20542054
hex2binary "$stapled_response" > "$TEMPDIR/stapled_ocsp_response.dd"
2055-
$OPENSSL ocsp -no_nonce -respin "$TEMPDIR/stapled_ocsp_response.dd" \
2056-
-issuer $TEMPDIR/hostcert_issuer.pem -verify_other $TEMPDIR/intermediatecerts.pem \
2057-
-CAfile <(cat $ADDTL_CA_FILES "$GOOD_CA_BUNDLE") -cert $HOSTCERT -text &> "$tmpfile"
2055+
if [[ "$stapled_response" =~ 06052[bB]0[eE]03021[aA] ]]; then
2056+
# Response appears to use SHA-1 in CertID
2057+
$OPENSSL ocsp -no_nonce -respin "$TEMPDIR/stapled_ocsp_response.dd" \
2058+
-issuer $TEMPDIR/hostcert_issuer.pem -verify_other $TEMPDIR/intermediatecerts.pem \
2059+
-CAfile <(cat $ADDTL_CA_FILES "$GOOD_CA_BUNDLE") -cert $HOSTCERT -text &> "$tmpfile"
2060+
success=$?
2061+
fi
2062+
if [[ $success -ne 0 ]] && [[ "$stapled_response" =~ 0609608648016503040201 ]]; then
2063+
# Response appears to use SHA-256 in CertID
2064+
$OPENSSL ocsp -sha256 -no_nonce -respin "$TEMPDIR/stapled_ocsp_response.dd" \
2065+
-issuer $TEMPDIR/hostcert_issuer.pem -verify_other $TEMPDIR/intermediatecerts.pem \
2066+
-CAfile <(cat $ADDTL_CA_FILES "$GOOD_CA_BUNDLE") -cert $HOSTCERT -text &> "$tmpfile"
2067+
success=$?
2068+
fi
20582069
else
20592070
host_header=${uri##http://}
20602071
host_header=${host_header%%/*}
@@ -2069,8 +2080,9 @@ check_revocation_ocsp() {
20692080
$OPENSSL ocsp -no_nonce ${host_header} -url "$uri" \
20702081
-issuer $TEMPDIR/hostcert_issuer.pem -verify_other $TEMPDIR/intermediatecerts.pem \
20712082
-CAfile <(cat $ADDTL_CA_FILES "$GOOD_CA_BUNDLE") -cert $HOSTCERT -text &> "$tmpfile"
2083+
success=$?
20722084
fi
2073-
if [[ $? -eq 0 ]] && grep -Fq "Response verify OK" "$tmpfile"; then
2085+
if [[ $success -eq 0 ]] && grep -Fq "Response verify OK" "$tmpfile"; then
20742086
response="$(grep -F "$HOSTCERT: " "$tmpfile")"
20752087
response="${response#$HOSTCERT: }"
20762088
response="${response%\.}"

0 commit comments

Comments
 (0)