Skip to content

Commit

Permalink
Fix LibreSSL returns 0 on failure
Browse files Browse the repository at this point in the history
In some cases LibreSSL's s_client returns a status of 0 even when the connection fails. In the cases in which this happens there always seems to be a line in the output of the form "SSL handshake has read 0 bytes and written ... bytes". The commit fixes the problem by not treating a connection as successful if the string "SSL handshake has read 0 bytes and written" is present.
  • Loading branch information
dcooper16 committed Nov 27, 2024
1 parent 701c606 commit b1f7759
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions testssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7823,7 +7823,7 @@ sclient_connect_successful() {
local re='Master-Key: ([^\
]*)'

[[ $1 -eq 0 ]] && connect_success=true
[[ $1 -eq 0 ]] && [[ ! "$server_hello" =~ SSL\ handshake\ has\ read\ 0\ bytes\ and\ written ]] && connect_success=true
if ! "$connect_success" && [[ "$server_hello" =~ $re ]]; then
[[ -n "${BASH_REMATCH[1]}" ]] && connect_success=true
fi
Expand Down Expand Up @@ -21825,7 +21825,7 @@ sclient_auth() {
]*)'
local connect_success=false

[[ $1 -eq 0 ]] && connect_success=true
[[ $1 -eq 0 ]] && [[ ! "$server_hello" =~ SSL\ handshake\ has\ read\ 0\ bytes\ and\ written ]] && connect_success=true

! "$connect_success" && [[ "$server_hello" =~ $re ]] && \
[[ -n "${BASH_REMATCH[1]}" ]] && connect_success=true
Expand Down

0 comments on commit b1f7759

Please sign in to comment.