Skip to content

Commit 93b9a37

Browse files
committed
Fix "ID resumption test failed" under Darwin (3.0)
Under Darwin using LibreSSL it was not possible to test for session resumption by session ID. This fixes the issue #2096 for 3.0 by checking not only the return value of the s_client hello but also whether a probable certificate is being returned.
1 parent de0f4f7 commit 93b9a37

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

testssl.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6175,17 +6175,22 @@ sub_session_resumption() {
61756175
addcmd+=" $protocol"
61766176
fi
61776177

6178-
$OPENSSL s_client $(s_client_options "$STARTTLS $BUGS -connect $NODEIP:$PORT $PROXY $SNI $addcmd -sess_out $sess_data") </dev/null &>/dev/null
6178+
$OPENSSL s_client $(s_client_options "$STARTTLS $BUGS -connect $NODEIP:$PORT $PROXY $SNI $addcmd -sess_out $sess_data") </dev/null &>$tmpfile
61796179
ret1=$?
61806180
if [[ $ret1 -ne 0 ]]; then
6181-
debugme echo -n "Couldn't connect #1 "
6182-
return 7
6181+
# MacOS and LibreSSL return 1 here, that's why we need to check whether the handshake contains e.g. a certificate
6182+
if [[ ! $(<$tmpfile) =~ -----.*\ CERTIFICATE----- ]]; then
6183+
debugme echo -n "Couldn't connect #1 "
6184+
return 7
6185+
fi
61836186
fi
61846187
if "$byID" && [[ ! "$OSSL_NAME" =~ LibreSSL ]] && \
61856188
( [[ $OSSL_VER_MAJOR.$OSSL_VER_MINOR == 1.1.1* ]] || [[ $OSSL_VER_MAJOR == 3 ]] ) && \
61866189
[[ ! -s "$sess_data" ]]; then
61876190
# it seems OpenSSL indicates no Session ID resumption by just not generating output
61886191
debugme echo -n "No session resumption byID (empty file)"
6192+
# If we want to check the presence of session data:
6193+
# [[ ! $(<$sess_data) =~ -----.*\ SSL\ SESSION\ PARAMETERS----- ]]
61896194
ret=2
61906195
else
61916196
$OPENSSL s_client $(s_client_options "$STARTTLS $BUGS -connect $NODEIP:$PORT $PROXY $SNI $addcmd -sess_in $sess_data") </dev/null >$tmpfile 2>$ERRFILE
@@ -6195,8 +6200,10 @@ sub_session_resumption() {
61956200
[[ -s "$sess_data" ]] && echo "not empty" || echo "empty"
61966201
fi
61976202
if [[ $ret2 -ne 0 ]]; then
6198-
debugme echo -n "Couldn't connect #2 "
6199-
return 7
6203+
if [[ ! $(<$tmpfile) =~ -----.*\ CERTIFICATE----- ]]; then
6204+
debugme echo -n "Couldn't connect #2 "
6205+
return 7
6206+
fi
62006207
fi
62016208
# "Reused" indicates session material was reused, "New": not
62026209
if grep -aq "^Reused" "$tmpfile"; then
@@ -6208,7 +6215,7 @@ sub_session_resumption() {
62086215
not_new_reused=true
62096216
fi
62106217
# Now get the line and compare the numbers "read" and "written" as a second criteria.
6211-
# If the "read" number is bigger: a new session ID was probably used
6218+
# If the "read" number is bigger: a new session ID was probably used.
62126219
rw_line="$(awk '/^SSL handshake has read/ { print $5" "$(NF-1) }' "$tmpfile" )"
62136220
rw_line=($rw_line)
62146221
if [[ "${rw_line[0]}" -gt "${rw_line[1]}" ]]; then

0 commit comments

Comments
 (0)