@@ -220,6 +220,7 @@ FNAME=${FNAME:-""} # file name to read commands from
220220FNAME_PREFIX=${FNAME_PREFIX:-""} # output filename prefix, see --outprefix
221221APPEND=${APPEND:-false} # append to csv/json file instead of overwriting it
222222[[ -z "$NODNS" ]] && declare NODNS # If unset it does all DNS lookups per default. "min" only for hosts or "none" at all
223+ NXCONNECT=${NXCONNECT:-invalid.} # For WSL this helps avoiding DNS requests to "invalid." which windows seem to handle delayed
223224HAS_IPv6=${HAS_IPv6:-false} # if you have OpenSSL with IPv6 support AND IPv6 networking set it to yes
224225ALL_CLIENTS=${ALL_CLIENTS:-false} # do you want to run all client simulation form all clients supplied by SSLlabs?
225226OFFENSIVE=${OFFENSIVE:-true} # do you want to include offensive vulnerability tests which may cause blocking by an IDS?
@@ -4790,11 +4791,13 @@ run_client_simulation() {
47904791 return $ret
47914792}
47924793
4793- # generic function whether $1 is supported by s_client ($2: string to display, currently nowhere being used)
4794+ # generic function whether $1 is supported by s_client ($2: string to display)
4795+ # Currently only used for protocols that's why we saved -connect $NXCONNECT.
4796+ #TODO: we need to consider to remove the two instances from where this is called.
47944797#
47954798locally_supported() {
47964799 [[ -n "$2" ]] && out "$2 "
4797- if $OPENSSL s_client "$1" -connect invalid. 2>&1 | grep -aiq "unknown option"; then
4800+ if $OPENSSL s_client "$1" 2>&1 | grep -aiq "unknown option"; then
47984801 prln_local_problem "$OPENSSL doesn't support \"s_client $1\""
47994802 return 7
48004803 fi
@@ -4814,9 +4817,9 @@ locally_supported() {
48144817run_prototest_openssl() {
48154818 local -i ret=0
48164819 local protos proto
4820+ local passed_check=false
48174821
4818- # check whether the protocol being tested is supported by $OPENSSL
4819- $OPENSSL s_client "$1" -connect invalid. 2>&1 | grep -aiq "unknown option" && return 7
4822+ $OPENSSL s_client "$1" 2>&1 | grep -aiq "unknown option" && return 7
48204823 case "$1" in
48214824 -ssl2) protos="-ssl2" ;;
48224825 -ssl3) protos="-ssl3" ;;
@@ -4825,6 +4828,8 @@ run_prototest_openssl() {
48254828 -tls1_2) protos="-no_ssl2"; "$HAS_TLS13" && protos+=" -no_tls1_3" ;;
48264829 -tls1_3) protos="" ;;
48274830 esac
4831+
4832+ #FIXME: we have here HAS_SSL(2|3) and more but we don't use that
48284833 $OPENSSL s_client $(s_client_options "-state $protos $STARTTLS $BUGS -connect $NODEIP:$PORT $PROXY $SNI") >$TMPFILE 2>&1 </dev/null
48294834 sclient_connect_successful $? $TMPFILE
48304835 ret=$?
@@ -16968,6 +16973,8 @@ find_openssl_binary() {
1696816973 elif [[ -e "/mnt/c/Windows/System32/bash.exe" ]] && test_openssl_suffix "$(dirname "$(type -p openssl)")"; then
1696916974 # 2. otherwise, only if on Bash on Windows, use system binaries only.
1697016975 SYSTEM2="WSL"
16976+ # Workaround for delayed responses of Windows DNS when using "invalid.", see #1738, #1812.
16977+ [[ $NXCONNECT == invalid. ]] && NXCONNECT=127.0.0.1:0
1697116978 elif test_openssl_suffix "$TESTSSL_INSTALL_DIR"; then
1697216979 : # 3. otherwise try openssl in path of testssl.sh
1697316980 elif test_openssl_suffix "$TESTSSL_INSTALL_DIR/bin"; then
@@ -17062,92 +17069,54 @@ find_openssl_binary() {
1706217069
1706317070 # This and all other occurrences we do a little trick using "invalid." to avoid plain and
1706417071 # link level DNS lookups. See issue #1418 and https://tools.ietf.org/html/rfc6761#section-6.4
17065- $OPENSSL s_client -ssl2 -connect invalid. 2>&1 | grep -aiq "unknown option" || \
17066- HAS_SSL2=true
17067-
17068- $OPENSSL s_client -ssl3 -connect invalid. 2>&1 | grep -aiq "unknown option" || \
17069- HAS_SSL3=true
17070-
17071- $OPENSSL s_client -tls1_3 -connect invalid. 2>&1 | grep -aiq "unknown option" || \
17072- HAS_TLS13=true
17073-
17074- $OPENSSL genpkey -algorithm X448 2>&1 | grep -aq "not found" || \
17075- HAS_X448=true
17076-
17077- $OPENSSL genpkey -algorithm X25519 2>&1 | grep -aq "not found" || \
17078- HAS_X25519=true
1707917072
17080- $OPENSSL s_client -no_ssl2 -connect invalid. 2>&1 | grep -aiq "unknown option" || \
17081- HAS_NO_SSL2=true
17073+ $OPENSSL s_client -ssl2 2>&1 | grep -aiq "unknown option" || HAS_SSL2=true
17074+ $OPENSSL s_client -ssl3 2>&1 | grep -aiq "unknown option" || HAS_SSL3=true
17075+ $OPENSSL s_client -tls1_3 2>&1 | grep -aiq "unknown option" || HAS_TLS13=true
17076+ $OPENSSL s_client -no_ssl2 2>&1 | grep -aiq "unknown option" || HAS_NO_SSL2=true
1708217077
17083- $OPENSSL s_client -noservername -connect invalid. 2>&1 | grep -aiq "unknown option " || \
17084- HAS_NOSERVERNAME =true
17078+ $OPENSSL genpkey -algorithm X448 2>&1 | grep -aq "not found " || HAS_X448=true
17079+ $OPENSSL genpkey -algorithm X25519 2>&1 | grep -aq "not found" || HAS_X25519 =true
1708517080
17086- $OPENSSL s_client -ciphersuites -connect invalid. 2>&1 | grep -aiq "unknown option" || \
17087- HAS_CIPHERSUITES =true
17081+ $OPENSSL pkey -help 2>&1 | grep -q Error || HAS_PKEY=true
17082+ $OPENSSL pkeyutl 2>&1 | grep -q Error || HAS_PKUTIL =true
1708817083
17089- $OPENSSL s_client -comp -connect invalid. 2>&1 | grep -aiq "unknown option" || \
17090- HAS_COMP =true
17084+ $OPENSSL s_client -noservername 2>&1 | grep -aiq "unknown option" || HAS_NOSERVERNAME=true
17085+ $OPENSSL s_client -ciphersuites 2>&1 | grep -aiq "unknown option" || HAS_CIPHERSUITES =true
1709117086
17092- $OPENSSL s_client -no_comp -connect invalid. 2>&1 | grep -aiq "unknown option" || \
17093- HAS_NO_COMP=true
17087+ $OPENSSL s_client -comp 2>&1 | grep -aiq "unknown option" || HAS_COMP=true
17088+ $OPENSSL s_client -no_comp 2>&1 | grep -aiq "unknown option" || HAS_NO_COMP=true
1709417089
1709517090 OPENSSL_NR_CIPHERS=$(count_ciphers "$(actually_supported_osslciphers 'ALL:COMPLEMENTOFALL' 'ALL')")
1709617091
17097- if $OPENSSL s_client -curves "${curves_ossl[0]}" -connect invalid. 2>&1 | grep -aiq "unknown option"; then
17092+ if $OPENSSL s_client -curves "${curves_ossl[0]}" -connect $NXCONNECT 2>&1 | grep -aiq "unknown option"; then
1709817093 for curve in "${curves_ossl[@]}"; do
17099- $OPENSSL s_client -groups $curve -connect invalid. :8443 2>&1 | grep -Eiaq "Error with command|unknown option|Failed to set groups"
17094+ $OPENSSL s_client -groups $curve -connect ${NXCONNECT%:*} :8443 2>&1 | grep -Eiaq "Error with command|unknown option|Failed to set groups"
1710017095 [[ $? -ne 0 ]] && OSSL_SUPPORTED_CURVES+=" $curve "
1710117096 done
1710217097 else
1710317098 HAS_CURVES=true
1710417099 for curve in "${curves_ossl[@]}"; do
17105- $OPENSSL s_client -curves $curve -connect invalid. 2>&1 | grep -Eiaq "Error with command|unknown option"
17100+ $OPENSSL s_client -curves $curve -connect $NXCONNECT 2>&1 | grep -Eiaq "Error with command|unknown option"
1710617101 [[ $? -ne 0 ]] && OSSL_SUPPORTED_CURVES+=" $curve "
1710717102 done
1710817103 fi
1710917104
17110- $OPENSSL pkey -help 2>&1 | grep -q Error || \
17111- HAS_PKEY=true
17112-
17113- $OPENSSL pkeyutl 2>&1 | grep -q Error || \
17114- HAS_PKUTIL=true
17115-
1711617105 # For the following we feel safe enough to query the s_client help functions.
1711717106 # That was not good enough for the previous lookups
1711817107 $OPENSSL s_client -help 2>$s_client_has
17108+ grep -qw '\-alpn' $s_client_has && HAS_ALPN=true
17109+ grep -qw '\-nextprotoneg' $s_client_has && HAS_NPN=true
17110+ grep -qw '\-fallback_scsv' $s_client_has && HAS_FALLBACK_SCSV=true
17111+ grep -q '\-proxy' $s_client_has && HAS_PROXY=true
17112+ grep -q '\-xmpp' $s_client_has && HAS_XMPP=true
1711917113
1712017114 $OPENSSL s_client -starttls foo 2>$s_client_starttls_has
17121-
17122- grep -qw '\-alpn' $s_client_has && \
17123- HAS_ALPN=true
17124-
17125- grep -qw '\-nextprotoneg' $s_client_has && \
17126- HAS_NPN=true
17127-
17128- grep -qw '\-fallback_scsv' $s_client_has && \
17129- HAS_FALLBACK_SCSV=true
17130-
17131- grep -q '\-proxy' $s_client_has && \
17132- HAS_PROXY=true
17133-
17134- grep -q '\-xmpp' $s_client_has && \
17135- HAS_XMPP=true
17136-
17137- grep -q 'postgres' $s_client_starttls_has && \
17138- HAS_POSTGRES=true
17139-
17140- grep -q 'mysql' $s_client_starttls_has && \
17141- HAS_MYSQL=true
17142-
17143- grep -q 'lmtp' $s_client_starttls_has && \
17144- HAS_LMTP=true
17145-
17146- grep -q 'nntp' $s_client_starttls_has && \
17147- HAS_NNTP=true
17148-
17149- grep -q 'irc' $s_client_starttls_has && \
17150- HAS_IRC=true
17115+ grep -q 'postgres' $s_client_starttls_has && HAS_POSTGRES=true
17116+ grep -q 'mysql' $s_client_starttls_has && HAS_MYSQL=true
17117+ grep -q 'lmtp' $s_client_starttls_has && HAS_LMTP=true
17118+ grep -q 'nntp' $s_client_starttls_has && HAS_NNTP=true
17119+ grep -q 'irc' $s_client_starttls_has && HAS_IRC=true
1715117120
1715217121 $OPENSSL enc -chacha20 -K 12345678901234567890123456789012 -iv 01000000123456789012345678901234 > /dev/null 2> /dev/null <<< "test"
1715317122 [[ $? -eq 0 ]] && HAS_CHACHA20=true
@@ -18519,7 +18488,7 @@ determine_optimal_proto() {
1851918488 elif "$all_failed" && ! "$ALL_FAILED_SOCKETS"; then
1852018489 if ! "$HAS_TLS13" && "$TLS13_ONLY"; then
1852118490 pr_magenta " $NODE:$PORT appears to support TLS 1.3 ONLY. You better use --openssl=<path_to_openssl_supporting_TLS_1.3>"
18522- if ! "$OSSL_SHORTCUT" || [[ ! -x /usr/bin/openssl ]] || /usr/bin/openssl s_client -tls1_3 -connect invalid. 2>&1 | grep -aiq "unknown option"; then
18491+ if ! "$OSSL_SHORTCUT" || [[ ! -x /usr/bin/openssl ]] || /usr/bin/openssl s_client -tls1_3 2>&1 | grep -aiq "unknown option"; then
1852318492 outln
1852418493 ignore_no_or_lame " Type \"yes\" to proceed and accept all scan problems" "yes"
1852518494 [[ $? -ne 0 ]] && exit $ERR_CLUELESS
0 commit comments