From f1eb3b85dee3278795ba1c9f583e50745efe0730 Mon Sep 17 00:00:00 2001 From: David Cooper Date: Wed, 1 Feb 2017 15:43:15 -0500 Subject: [PATCH 1/5] Handle renaming of the Supported Elliptic Curves Extension RFC 4492 introduced the Supported Elliptic Curves Extension, but this extension was renamed Supported Groups in RFC 7919. Following RFC 7919 (and TLSv1.3), `parse_tls_serverhello()` refers to this extension as "supported groups/#10". Since, at the moment, OpenSSL's s_client refers to this extension as "elliptic curves/#10", the extension sometimes appears twice in the "TLS extensions" line, if it is detected by both OpenSSL (in `get_server_certificate()`) and `tls_sockets()` (in `determine_tls_extensions()`): ``` TLS extensions (standard) "renegotiation info/#65281" "elliptic curves/#10" "EC point formats/#11" "supported groups/#10" ``` This PR fixes the problem of the extension appearing twice in the "TLS extensions" line by replacing any instances of "elliptic curves/#10" with "supported_groups/#10" in the `$tls_extensions` line extracted from `$OPENSSL s_client`. This PR also changes "supported groups/#10" to "supported_groups/#10" in `parse_tls_serverhello()`, since the current development branch of OpenSSL uses "supported_groups" to refer to this extension (see https://github.com/openssl/openssl/pull/1825). --- testssl.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/testssl.sh b/testssl.sh index 0cc0573..4e43e56 100755 --- a/testssl.sh +++ b/testssl.sh @@ -5427,7 +5427,10 @@ determine_tls_extensions() { success=$? fi if [[ $success -eq 0 ]]; then - tls_extensions=$(grep -a 'TLS server extension ' $TMPFILE | sed -e 's/TLS server extension //g' -e 's/\" (id=/\/#/g' -e 's/,.*$/,/g' -e 's/),$/\"/g') + tls_extensions=$(grep -a 'TLS server extension ' $TMPFILE | \ + sed -e 's/TLS server extension //g' -e 's/\" (id=/\/#/g' \ + -e 's/,.*$/,/g' -e 's/),$/\"/g' \ + -e 's/elliptic curves\/#10/supported_groups\/#10/g') tls_extensions=$(echo $tls_extensions) # into one line fi tmpfile_handle $FUNCNAME.txt @@ -5519,7 +5522,10 @@ get_server_certificate() { # this is not beautiful (grep+sed) # but maybe we should just get the ids and do a private matching, according to # https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml - tls_extensions=$(grep -a 'TLS server extension ' $TMPFILE | sed -e 's/TLS server extension //g' -e 's/\" (id=/\/#/g' -e 's/,.*$/,/g' -e 's/),$/\"/g') + tls_extensions=$(grep -a 'TLS server extension ' $TMPFILE | \ + sed -e 's/TLS server extension //g' -e 's/\" (id=/\/#/g' \ + -e 's/,.*$/,/g' -e 's/),$/\"/g' \ + -e 's/elliptic curves\/#10/supported_groups\/#10/g') tls_extensions=$(echo $tls_extensions) # into one line # check to see if any new TLS extensions were returned and add any new ones to TLS_EXTENSIONS @@ -8036,7 +8042,7 @@ parse_tls_serverhello() { 0007) tls_extensions+=" \"client authz/#7\"" ;; 0008) tls_extensions+=" \"server authz/#8\"" ;; 0009) tls_extensions+=" \"cert type/#9\"" ;; - 000A) tls_extensions+=" \"supported groups/#10\"" ;; + 000A) tls_extensions+=" \"supported_groups/#10\"" ;; 000B) tls_extensions+=" \"EC point formats/#11\"" ;; 000C) tls_extensions+=" \"SRP/#12\"" ;; 000D) tls_extensions+=" \"signature algorithms/#13\"" ;; From 6140aa8b8cd965f66ec926b22a57d583a48cdb62 Mon Sep 17 00:00:00 2001 From: Thomas Ward Date: Tue, 7 Feb 2017 15:59:09 -0500 Subject: [PATCH 2/5] Attempt to force system binaries for WSL --- testssl.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/testssl.sh b/testssl.sh index 6d2462b..9d500e0 100755 --- a/testssl.sh +++ b/testssl.sh @@ -10769,10 +10769,12 @@ find_openssl_binary() { outln " Looking some place else ..." elif [[ -x "$OPENSSL" ]]; then : # 1. all ok supplied $OPENSSL was found and has excutable bit set -- testrun comes below + elif [ -e "/mnt/c/Windows/System32/bash.exe" ] && test_openssl_suffix "$(dirname "$(which openssl)")"; then + : # 2. otherwise, only if on Bash on Windows, use system binaries only. elif test_openssl_suffix $RUN_DIR; then - : # 2. otherwise try openssl in path of testssl.sh + : # 3. otherwise try openssl in path of testssl.sh elif test_openssl_suffix $RUN_DIR/bin; then - : # 3. otherwise here, this is supposed to be the standard --platform independed path in the future!!! + : # 4. otherwise here, this is supposed to be the standard --platform independed path in the future!!! elif test_openssl_suffix "$(dirname "$(which openssl)")"; then : # 5. we tried hard and failed, so now we use the system binaries fi From 0d993427a30f8963ff40f0b6cd786ac46bb4e3db Mon Sep 17 00:00:00 2001 From: Dirk Date: Tue, 7 Feb 2017 23:08:29 +0100 Subject: [PATCH 3/5] - enabling TLS 1.2 via sockets - enabling sockets in run_protocols STARTTLS per default - minor output polishing --- testssl.sh | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/testssl.sh b/testssl.sh index 6d2462b..0597af2 100755 --- a/testssl.sh +++ b/testssl.sh @@ -616,6 +616,7 @@ pr_italicln() { pr_italic "$1" ; outln; } pr_strikethru() { [[ "$COLOR" -ne 0 ]] && out "\033[9m$1" || out "$1"; pr_off; } # ugly! pr_strikethruln() { pr_strikethru "$1" ; outln; } pr_underline() { [[ "$COLOR" -ne 0 ]] && out "\033[4m$1" || out "$1"; pr_off; } +pr_underlineln() { pr_underline "$1"; outln; } pr_reverse() { [[ "$COLOR" -ne 0 ]] && out "\033[7m$1" || out "$1"; pr_off; } pr_reverse_bold() { [[ "$COLOR" -ne 0 ]] && out "\033[7m\033[1m$1" || out "$1"; pr_off; } @@ -2626,7 +2627,7 @@ run_allciphers() { outln if "$using_sockets"; then - pr_headlineln " Testing $nr_ciphers_tested via OpenSSL and sockets against the server, ordered by encryption strength " + pr_headlineln " Testing $nr_ciphers_tested ciphers via OpenSSL plus sockets against the server, ordered by encryption strength " else pr_headlineln " Testing all $nr_ciphers_tested locally available ciphers against the server, ordered by encryption strength " [[ $TLS_NR_CIPHERS == 0 ]] && ! "$SSL_NATIVE" && ! "$FAST" && pr_warning " Cipher mapping not available, doing a fallback to openssl" @@ -2803,7 +2804,7 @@ run_cipher_per_proto() { outln if "$using_sockets"; then - pr_headlineln " Testing per protocol via OpenSSL and sockets against the server, ordered by encryption strength " + pr_headlineln " Testing ciphers per protocol via OpenSSL plus sockets against the server, ordered by encryption strength " else pr_headlineln " Testing all locally available ciphers per protocol against the server, ordered by encryption strength " [[ $TLS_NR_CIPHERS == 0 ]] && ! "$SSL_NATIVE" && ! "$FAST" && pr_warning " Cipher mapping not available, doing a fallback to openssl" @@ -4214,18 +4215,13 @@ run_protocols() { if "$SSL_NATIVE"; then using_sockets=false - pr_headlineln "(via native openssl)" + pr_underlineln "via native openssl" else + using_sockets=true if [[ -n "$STARTTLS" ]]; then - pr_headlineln "(via openssl, SSLv2 via sockets) " - using_sockets=false + pr_underlineln "via sockets " else - using_sockets=true - if "$EXPERIMENTAL"; then - pr_headlineln "(via sockets except SPDY+HTTP2) " - else - pr_headlineln "(via sockets except TLS 1.2, SPDY+HTTP2) " - fi + pr_underlineln "via sockets except SPDY+HTTP2 " fi fi outln @@ -4429,7 +4425,7 @@ run_protocols() { esac pr_bold " TLS 1.2 "; - if "$using_sockets" && "$EXPERIMENTAL"; then #TODO: IIS servers do have a problem here with our handshake + if "$using_sockets"; then tls_sockets "03" "$TLS12_CIPHER" else run_prototest_openssl "-tls1_2" @@ -4549,7 +4545,7 @@ run_std_cipherlists() { read_dhbits_from_file() { local bits what_dh temp curve="" local add="" - local old_fart=" (openssl cannot show DH bits)" + local old_fart=" (your $OPENSSL cannot show DH bits)" temp=$(awk -F': ' '/^Server Temp Key/ { print $2 }' "$1") # extract line what_dh=$(awk -F',' '{ print $1 }' <<< $temp) @@ -5252,7 +5248,7 @@ determine_trust() { if [[ $OSSL_VER_MAJOR.$OSSL_VER_MINOR != "1.0.2" ]] && \ [[ $OSSL_VER_MAJOR.$OSSL_VER_MINOR != "1.1.0" ]] && \ [[ $OSSL_VER_MAJOR.$OSSL_VER_MINOR != "1.1.1" ]]; then - addtl_warning="(Your openssl <= 1.0.2 might be too unreliable to determine trust)" + addtl_warning="(Your $OPENSSL <= 1.0.2 might be too unreliable to determine trust)" fileout "${json_prefix}chain_of_trust_warn" "WARN" "$addtl_warning" fi debugme outln @@ -6500,7 +6496,7 @@ run_pfs() { [[ $TLS_NR_CIPHERS == 0 ]] && using_sockets=false outln - pr_headlineln " Testing robust (perfect) forward secrecy, (P)FS -- omitting Null Authentication/Encryption, 3DES, RC4 " + pr_headline " Testing robust (perfect) forward secrecy"; pr_underlineln ", (P)FS -- omitting Null Authentication/Encryption, 3DES, RC4 " if ! "$using_sockets"; then [[ $TLS_NR_CIPHERS == 0 ]] && ! "$SSL_NATIVE" && ! "$FAST" && pr_warning " Cipher mapping not available, doing a fallback to openssl" if ! "$HAS_DH_BITS" && "$WIDE"; then From 0200100750032dcc9c7eede87369d2414f07301a Mon Sep 17 00:00:00 2001 From: Dirk Date: Wed, 8 Feb 2017 08:58:28 +0100 Subject: [PATCH 4/5] see #620 --- testssl.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testssl.sh b/testssl.sh index 886ca4f..1d0b9ef 100755 --- a/testssl.sh +++ b/testssl.sh @@ -10771,7 +10771,7 @@ find_openssl_binary() { outln " Looking some place else ..." elif [[ -x "$OPENSSL" ]]; then : # 1. all ok supplied $OPENSSL was found and has excutable bit set -- testrun comes below - elif [ -e "/mnt/c/Windows/System32/bash.exe" ] && test_openssl_suffix "$(dirname "$(which openssl)")"; then + elif [[ -e "/mnt/c/Windows/System32/bash.exe" ]] && test_openssl_suffix "$(dirname "$(which openssl)")"; then : # 2. otherwise, only if on Bash on Windows, use system binaries only. elif test_openssl_suffix $RUN_DIR; then : # 3. otherwise try openssl in path of testssl.sh From 386aa924481cefcaf4e04af510eea9a9dc483f8d Mon Sep 17 00:00:00 2001 From: Dirk Date: Wed, 8 Feb 2017 09:08:05 +0100 Subject: [PATCH 5/5] keep detected status of WSL / bash on windows in a variable, see also #620 --- testssl.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/testssl.sh b/testssl.sh index 1d0b9ef..489995c 100755 --- a/testssl.sh +++ b/testssl.sh @@ -110,6 +110,7 @@ else readonly REL_DATE=$(tail -5 "$0" | awk '/dirkw Exp/ { print $5 }') fi readonly SYSTEM=$(uname -s) +SYSTEM2="" # currently only being used for WSL = bash on windows date -d @735275209 >/dev/null 2>&1 && \ readonly HAS_GNUDATE=true || \ readonly HAS_GNUDATE=false @@ -10772,7 +10773,8 @@ find_openssl_binary() { elif [[ -x "$OPENSSL" ]]; then : # 1. all ok supplied $OPENSSL was found and has excutable bit set -- testrun comes below elif [[ -e "/mnt/c/Windows/System32/bash.exe" ]] && test_openssl_suffix "$(dirname "$(which openssl)")"; then - : # 2. otherwise, only if on Bash on Windows, use system binaries only. + # 2. otherwise, only if on Bash on Windows, use system binaries only. + SYSTEM2="WSL" elif test_openssl_suffix $RUN_DIR; then : # 3. otherwise try openssl in path of testssl.sh elif test_openssl_suffix $RUN_DIR/bin; then @@ -11039,6 +11041,7 @@ bash version: ${BASH_VERSINFO[0]}.${BASH_VERSINFO[1]}.${BASH_VERSINFO[2]} status: ${BASH_VERSINFO[4]} machine: ${BASH_VERSINFO[5]} operating system: $SYSTEM +os constraint: $SYSTEM2 shellopts: $SHELLOPTS $($OPENSSL version -a)