Skip to content

Commit 8e55576

Browse files
authored
Merge pull request #2704 from dcooper16/ocsp_check_rev_ossl_ver_30
OpenSSL version check in check_revocation_ocsp()
2 parents dd188c1 + c58d6cf commit 8e55576

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

testssl.sh

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ TERM_CURRPOS=0 # custom line wrappi
188188
#
189189
# Following variables make use of $ENV and can be used like "OPENSSL=<myprivate_path_to_openssl> ./testssl.sh <URI>"
190190
declare -x OPENSSL
191+
OPENSSL2=${OPENSSL2:-/usr/bin/openssl} # This will be openssl version >=1.1.1 (auto determined) as opposed to openssl-bad (OPENSSL)
191192
OPENSSL_TIMEOUT=${OPENSSL_TIMEOUT:-""} # Default connect timeout with openssl before we call the server side unreachable
192193
CONNECT_TIMEOUT=${CONNECT_TIMEOUT:-""} # Default connect timeout with sockets before we call the server side unreachable
193194
PHONE_OUT=${PHONE_OUT:-false} # Whether testssl can retrieve CRLs and OCSP
@@ -1835,7 +1836,7 @@ check_revocation_ocsp() {
18351836
local host_header=""
18361837
local openssl_bin="$OPENSSL"
18371838
local addtl_warning=""
1838-
local smartswitch=false
1839+
local ossl_name="$OSSL_NAME" ossl_ver="$OSSL_VER"
18391840

18401841
"$PHONE_OUT" || [[ -n "$stapled_response" ]] || return 0
18411842
[[ -n "$GOOD_CA_BUNDLE" ]] || return 0
@@ -1859,8 +1860,10 @@ check_revocation_ocsp() {
18591860
# the vendor supplied binary if available, see #2516 and probably also #2667 and #1275
18601861
if [[ -x "$OPENSSL2" ]]; then
18611862
openssl_bin="$OPENSSL2"
1862-
smartswitch=true
18631863
[[ $DEBUG -ge 3 ]] && echo "Switching to $openssl_bin "
1864+
ossl_ver="$($openssl_bin version -v 2>/dev/null)"
1865+
ossl_name="${ossl_ver%% *}"
1866+
ossl_ver="${ossl_ver#$ossl_name }"
18641867
fi
18651868
else
18661869
addtl_warning="(a segfault indicates here you need to test this with another binary)"
@@ -1871,16 +1874,9 @@ check_revocation_ocsp() {
18711874
# The following is the default (like "-header Host r11.o.lencr.org")
18721875
host_header="-header Host ${host_header}"
18731876

1874-
if "$smartswitch" ; then
1875-
case $(openssl version -v | awk -F' ' '{ print $2 }') in
1876-
# for those versions it's "-header Host=r11.o.lencr.org"
1877-
3.*|1.1*) host_header=${host_header/Host /Host=} ;;
1878-
esac
1879-
else
1880-
case $OSSL_VER_MAJOR.$OSSL_VER_MINOR in
1881-
3.*|1.1*) host_header=${host_header/Host /Host=} ;;
1882-
esac
1883-
fi
1877+
case "$ossl_ver" in
1878+
3.*|1.1*) [[ ! "$ossl_name" =~ LibreSSL ]] && host_header=${host_header/Host /Host=} ;;
1879+
esac
18841880

18851881
$openssl_bin ocsp -no_nonce ${host_header} -url "$uri" \
18861882
-issuer $TEMPDIR/hostcert_issuer.pem -verify_other $TEMPDIR/intermediatecerts.pem \

0 commit comments

Comments
 (0)