Skip to content

Commit a0f1ea0

Browse files
authored
Fix #2896
This commit fixes #2896. This commit avoids modifying the ADDTL_CA_FILES environment variable, and instead substitutes spaces for commas whenever the variable is used.
1 parent c4856be commit a0f1ea0

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

testssl.sh

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,9 +2030,9 @@ check_revocation_crl() {
20302030
fi
20312031
fi
20322032
if grep -qe '-----BEGIN CERTIFICATE-----' $TEMPDIR/intermediatecerts.pem; then
2033-
$OPENSSL verify -crl_check -CAfile <(cat $ADDTL_CA_FILES "$GOOD_CA_BUNDLE" "${tmpfile%%.crl}.pem") -untrusted $TEMPDIR/intermediatecerts.pem $HOSTCERT &> "${tmpfile%%.crl}.err"
2033+
$OPENSSL verify -crl_check -CAfile <(cat ${ADDTL_CA_FILES//,/ } "$GOOD_CA_BUNDLE" "${tmpfile%%.crl}.pem") -untrusted $TEMPDIR/intermediatecerts.pem $HOSTCERT &> "${tmpfile%%.crl}.err"
20342034
else
2035-
$OPENSSL verify -crl_check -CAfile <(cat $ADDTL_CA_FILES "$GOOD_CA_BUNDLE" "${tmpfile%%.crl}.pem") $HOSTCERT &> "${tmpfile%%.crl}.err"
2035+
$OPENSSL verify -crl_check -CAfile <(cat ${ADDTL_CA_FILES//,/ } "$GOOD_CA_BUNDLE" "${tmpfile%%.crl}.pem") $HOSTCERT &> "${tmpfile%%.crl}.err"
20362036
fi
20372037
if [[ $? -eq 0 ]]; then
20382038
out ", "
@@ -2090,14 +2090,14 @@ check_revocation_ocsp() {
20902090
# Response appears to use SHA-1 in CertID
20912091
$OPENSSL ocsp -no_nonce -respin "$TEMPDIR/stapled_ocsp_response.dd" \
20922092
-issuer $TEMPDIR/hostcert_issuer.pem -verify_other $TEMPDIR/intermediatecerts.pem \
2093-
-CAfile <(cat $ADDTL_CA_FILES "$GOOD_CA_BUNDLE") -cert $HOSTCERT -text &> "$tmpfile"
2093+
-CAfile <(cat ${ADDTL_CA_FILES//,/ } "$GOOD_CA_BUNDLE") -cert $HOSTCERT -text &> "$tmpfile"
20942094
success=$?
20952095
fi
20962096
if [[ $success -ne 0 ]] && [[ "$stapled_response" =~ 0609608648016503040201 ]]; then
20972097
# Response appears to use SHA-256 in CertID
20982098
$OPENSSL ocsp -sha256 -no_nonce -respin "$TEMPDIR/stapled_ocsp_response.dd" \
20992099
-issuer $TEMPDIR/hostcert_issuer.pem -verify_other $TEMPDIR/intermediatecerts.pem \
2100-
-CAfile <(cat $ADDTL_CA_FILES "$GOOD_CA_BUNDLE") -cert $HOSTCERT -text &> "$tmpfile"
2100+
-CAfile <(cat ${ADDTL_CA_FILES//,/ } "$GOOD_CA_BUNDLE") -cert $HOSTCERT -text &> "$tmpfile"
21012101
success=$?
21022102
fi
21032103
else
@@ -2128,7 +2128,7 @@ check_revocation_ocsp() {
21282128
fi
21292129
$openssl_bin ocsp -no_nonce ${host_header} -url "$uri" \
21302130
-issuer $TEMPDIR/hostcert_issuer.pem -verify_other $TEMPDIR/intermediatecerts.pem \
2131-
-CAfile <(cat $ADDTL_CA_FILES "$GOOD_CA_BUNDLE") -cert $HOSTCERT -text &> "$tmpfile"
2131+
-CAfile <(cat ${ADDTL_CA_FILES//,/ } "$GOOD_CA_BUNDLE") -cert $HOSTCERT -text &> "$tmpfile"
21322132
success=$?
21332133
fi
21342134

@@ -7810,9 +7810,9 @@ determine_trust() {
78107810
# in a subshell because that should be valid here only
78117811
(export SSL_CERT_DIR="/dev/null"; export SSL_CERT_FILE="/dev/null"
78127812
if [[ $certificates_provided -ge 2 ]]; then
7813-
$OPENSSL verify $TRUSTED1ST -purpose sslserver -CAfile <(cat $ADDTL_CA_FILES "$bundle_fname") -untrusted $TEMPDIR/intermediatecerts.pem $HOSTCERT >$TEMPDIR/${certificate_file[i]}.1 2>$TEMPDIR/${certificate_file[i]}.2
7813+
$OPENSSL verify $TRUSTED1ST -purpose sslserver -CAfile <(cat ${ADDTL_CA_FILES//,/ } "$bundle_fname") -untrusted $TEMPDIR/intermediatecerts.pem $HOSTCERT >$TEMPDIR/${certificate_file[i]}.1 2>$TEMPDIR/${certificate_file[i]}.2
78147814
else
7815-
$OPENSSL verify $TRUSTED1ST -purpose sslserver -CAfile <(cat $ADDTL_CA_FILES "$bundle_fname") $HOSTCERT >$TEMPDIR/${certificate_file[i]}.1 2>$TEMPDIR/${certificate_file[i]}.2
7815+
$OPENSSL verify $TRUSTED1ST -purpose sslserver -CAfile <(cat ${ADDTL_CA_FILES//,/ } "$bundle_fname") $HOSTCERT >$TEMPDIR/${certificate_file[i]}.1 2>$TEMPDIR/${certificate_file[i]}.2
78167816
fi)
78177817
verify_retcode[i]=$(awk '/error [1-9][0-9]? at [0-9]+ depth lookup:/ { if (!found) {print $2; found=1} }' $TEMPDIR/${certificate_file[i]}.1 $TEMPDIR/${certificate_file[i]}.2)
78187818
[[ -z "${verify_retcode[i]}" ]] && verify_retcode[i]=0
@@ -24747,10 +24747,8 @@ parse_cmd_line() {
2474724747
fi
2474824748
if [[ -d "${ADDTL_CA_FILES}" ]]; then
2474924749
ADDTL_CA_FILES="$ADDTL_CA_FILES/*.pem"
24750-
else
24751-
ADDTL_CA_FILES="${ADDTL_CA_FILES//,/ }"
2475224750
fi
24753-
for fname in ${ADDTL_CA_FILES}; do
24751+
for fname in ${ADDTL_CA_FILES//,/ }; do
2475424752
[[ -s "$fname" ]] || fatal_cmd_line "The CA file \"$fname\" does not exist" $ERR_RESOURCE
2475524753
grep -q 'BEGIN CERTIFICATE' "$fname" || fatal_cmd_line "\"$fname\" is not CA file in PEM format" $ERR_RESOURCE
2475624754
done

0 commit comments

Comments
 (0)