From aab7e028c2caf9ae4faac0c0220d59440efbf2c5 Mon Sep 17 00:00:00 2001 From: David Cooper Date: Wed, 13 Nov 2019 10:46:51 -0500 Subject: [PATCH] Enhance run_protocols() in --ssl-native mode When tls_sockets() is used for run_protocols(), for each protocol version the results will indicate whether the server responded to a ClientHello for that protocol version with (1) a ServerHello for that same protocol version, (2) a ServerHello for a different (hopefully lower) protocol version, or (3) a handshake failure. Currently, however, run_prototest_openssl() does not distinguish between cases in which the server responds with a ServerHello for a different (hopefully lower) protocol version and cases in which the server responds with a handshake failure. This PR changes run_prototest_openssl() so that it distinguishes between these two cases (as long as $OPENSSL supports the protocol version specified in the ServerHello). Making use of the additional information provided by run_prototest_openssl(), this PR also modifies run_protocols() to check that version negotiation was performed correctly even if $using_sockets is false. Note that one special case needed to be addressed. If an SSLv3-only server is being tested using an $OPENSSL that does not support SSLv3, then $latest_supported must not be set to SSLv3. In the case of a server like this, it is possible that support for SSLv3 will be determined by determine_optimal_sockets_params(), which will cause run_protocols() to report that the server supports SSLv3, even though $OPENSSL does not support SSLv3 and testing is being performed in --ssl-native mode. If $latest_supported were set, then later tests in run_protocols() would incorrectly report a version negotiation failure, even though the failure to connect was a result of a limitation of $OPENSSL rather than a fault of the server. --- testssl.sh | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/testssl.sh b/testssl.sh index 7196282..1deb5a7 100755 --- a/testssl.sh +++ b/testssl.sh @@ -4795,10 +4795,19 @@ locally_supported() { # run_prototest_openssl() { local -i ret=0 + local protos proto # check whether the protocol being tested is supported by $OPENSSL $OPENSSL s_client "$1" -connect x 2>&1 | grep -aq "unknown option" && return 7 - $OPENSSL s_client $(s_client_options "-state $1 $STARTTLS $BUGS -connect $NODEIP:$PORT $PROXY $SNI") >$TMPFILE 2>&1 $TMPFILE 2>&1 $TMPFILE 2>&1 $TMPFILE 2>&1