Skip to content

Commit 30f80cf

Browse files
authored
Merge pull request #2561 from drwetter/fix_1312
Fix 1312
2 parents 9efe597 + 733c2d3 commit 30f80cf

File tree

5 files changed

+56
-25
lines changed

5 files changed

+56
-25
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
* Compatible to GNU grep 3.8
4747
* Don't use external pwd command anymore
4848
* Doesn't hang anymore when there's no local resolver
49-
* Added --mtls feature to support client authentication
49+
* Added --mtls feature to support client authentication
50+
* If a TLS 1.3 host is tested and e.g. /usr/bin/openssl supports it, it'll automagically will switch to it
5051

5152

5253
### Features implemented / improvements in 3.0

doc/testssl.1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Any single check switch supplied as an argument prevents testssl\.sh from doing
141141
.P
142142
\fB\-f, \-\-fs, \-\-nsa, \-\-forward\-secrecy\fR Checks robust forward secrecy key exchange\. "Robust" means that ciphers having intrinsic severe weaknesses like Null Authentication or Encryption, 3DES and RC4 won't be considered here\. There shouldn't be the wrong impression that a secure key exchange has been taking place and everything is fine when in reality the encryption sucks\. Also this section lists the available elliptical curves and Diffie Hellman groups, as well as FFDHE groups (TLS 1\.2 and TLS 1\.3)\.
143143
.P
144-
\fB\-p, \-\-protocols\fR checks TLS/SSL protocols SSLv2, SSLv3, TLS 1\.0 through TLS 1\.3 and for HTTP: SPDY (NPN) and ALPN, a\.k\.a\. HTTP/2\. For TLS 1\.3 several drafts (from 18 on) and final are supported and being tested for\.
144+
\fB\-p, \-\-protocols\fR checks TLS/SSL protocols SSLv2, SSLv3, TLS 1\.0 through TLS 1\.3 and for HTTP: SPDY (NPN) and ALPN, a\.k\.a\. HTTP/2\. For TLS 1\.3 several drafts (from 18 on) and final are supported and being tested for\. Note the supplied openssl\-bad version doesn't support TLS 1\.3 \. As the check for TLS 1\.3 will be done in sockets this normally does not pose a problem\. However if a TLS\-1\.3\-only host is encountered and to have a complete test coverage (e.g. header checks) \fB/usr/bin/openssl\fR (or the content of \fBOPENSSL2\fR) is checked for existence and support of TLS 1\.3 and if those tests succeeded it will be switched to this binary\. A message will notify you\.
145145
.P
146146
\fB\-P, \-\-server\-preference, \-\-preference\fR displays the servers preferences: cipher order, with used openssl client: negotiated protocol and cipher\. If there's a cipher order enforced by the server it displays it for each protocol (openssl+sockets)\. If there's not, it displays instead which ciphers from the server were picked with each protocol\.
147147
.P
@@ -418,6 +418,10 @@ MAX_SOCKET_FAIL: A number which tells testssl\.sh how often a TCP socket connect
418418
MAX_OSSL_FAIL: A number which tells testssl\.sh how often an OpenSSL s_client connect may fail before the program gives up and terminates\. The default is 2\. You can increase it to a higher value if you frequently see a message like \fIFatal error: repeated TCP connect problems, giving up\fR\.
419419
.IP "\[ci]" 4
420420
MAX_HEADER_FAIL: A number which tells testssl\.sh how often a HTTP GET request over OpenSSL may return an empty file before the program gives up and terminates\. The default is 3\. Also here you can increase the threshold when you spot messages like \fIFatal error: repeated HTTP header connect problems, doesn't make sense to continue\fR\.
421+
.IP "\[ci]" 4
422+
OPENSSL2 can be used to supply an alternative openssl version\. This only makes sense if you want to amend the supplied version in \fBbin/\fR which lacks TLS 1\.3 support with a version which does not and is not in \fB/usr/bin/openssl\fR.
423+
.IP "\[ci]" 4
424+
OSSL_SHORTCUT can be set to true when you run interactively and don't want to switch automatically to \fB/usr/bin/openssl\fR (\fBOPENSSL2\fR) if you encounter a TLS 1\.3-only host\.
421425
.IP "" 0
422426
.SS "RATING"
423427
This program has a near\-complete implementation of SSL Labs's 'SSL Server Rating Guide \fIhttps://github\.com/ssllabs/research/wiki/SSL\-Server\-Rating\-Guide\fR'\.

doc/testssl.1.html

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/testssl.1.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ Any single check switch supplied as an argument prevents testssl.sh from doing a
175175

176176
`-f, --fs, --nsa, --forward-secrecy` Checks robust forward secrecy key exchange. "Robust" means that ciphers having intrinsic severe weaknesses like Null Authentication or Encryption, 3DES and RC4 won't be considered here. There shouldn't be the wrong impression that a secure key exchange has been taking place and everything is fine when in reality the encryption sucks. Also this section lists the available elliptical curves and Diffie Hellman groups, as well as FFDHE groups (TLS 1.2 and TLS 1.3).
177177

178-
`-p, --protocols` checks TLS/SSL protocols SSLv2, SSLv3, TLS 1.0 through TLS 1.3 and for HTTP: SPDY (NPN) and ALPN, a.k.a. HTTP/2. For TLS 1.3 several drafts (from 18 on) and final are supported and being tested for.
178+
`-p, --protocols` checks TLS/SSL protocols SSLv2, SSLv3, TLS 1.0 through TLS 1.3 and for HTTP: SPDY (NPN) and ALPN, a.k.a. HTTP/2. For TLS 1.3 several drafts (from 18 on) and final are supported and being tested for. Note the supplied openssl-bad version doesn't support TLS 1.3 . As the check for TLS 1.3 will be done in sockets this normally does not pose a problem. However if a TLS-1.3-only host is encountered and to have a complete test coverage (e.g. header checks) `/usr/bin/openssl` (or the content of `OPENSSL2`) is checked for existence and support of TLS 1.3 and if those tests succeeded it will be switched to this binary. A message will notify you.
179179

180180
`-P, --server-preference, --preference` displays the servers preferences: cipher order, with used openssl client: negotiated protocol and cipher. If there's a cipher order enforced by the server it displays it for each protocol (openssl+sockets). If there's not, it displays instead which ciphers from the server were picked with each protocol.
181181

@@ -403,6 +403,9 @@ Except the environment variables mentioned above which can replace command line
403403
* MAX_SOCKET_FAIL: A number which tells testssl.sh how often a TCP socket connection may fail before the program gives up and terminates. The default is 2. You can increase it to a higher value if you frequently see a message like *Fatal error: repeated openssl s_client connect problem, doesn't make sense to continue*.
404404
* MAX_OSSL_FAIL: A number which tells testssl.sh how often an OpenSSL s_client connect may fail before the program gives up and terminates. The default is 2. You can increase it to a higher value if you frequently see a message like *Fatal error: repeated TCP connect problems, giving up*.
405405
* MAX_HEADER_FAIL: A number which tells testssl.sh how often a HTTP GET request over OpenSSL may return an empty file before the program gives up and terminates. The default is 3. Also here you can increase the threshold when you spot messages like *Fatal error: repeated HTTP header connect problems, doesn't make sense to continue*.
406+
* OPENSSL2 can be used to supply an alternative openssl version. This only makes sense if you want to amend the supplied version in `bin/` which lacks TLS 1.3 support with a version which doesn not and is not in `/usr/bin/openssl`.
407+
* OSSL_SHORTCUT can be set to true when you run interactively and don't want to switch automatically to `/usr/bin/openssl` (`OPENSSL2`) if you encounter a TLS 1.3-only host.
408+
406409

407410
### RATING
408411

testssl.sh

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,10 @@ SYSTEM2="" # currently only being used for WSL = ba
243243
PRINTF="" # which external printf to use. Empty presets the internal one, see #1130
244244
CIPHERS_BY_STRENGTH_FILE=""
245245
TLS_DATA_FILE="" # mandatory file for socket-based handshakes
246-
OPENSSL="" # If you run this from GitHub it's ~/bin/openssl.$(uname).$(uname -m) otherwise /usr/bin/openssl
247-
OPENSSL2="" # When running from GitHub, this will be openssl version >=1.1.1 (auto determined)
248-
OPENSSL2_HAS_TLS_1_3=false # If we run with supplied binary AND /usr/bin/openssl supports TLS 1.3 this is set to true
246+
OPENSSL="" # ~/bin/openssl.$(uname).$(uname -m) if you run this from GitHub. Linux otherwise probably /usr/bin/openssl
247+
OPENSSL2=${OPENSSL2:-/usr/bin/openssl} # This will be openssl version >=1.1.1 (auto determined) as opposed to openssl-bad (OPENSSL)
248+
OPENSSL2_HAS_TLS_1_3=false # If we run with supplied binary AND $OPENSSL2 supports TLS 1.3 this will be set to true
249+
OSSL_SHORTCUT=${OSSL_SHORTCUT:-true} # Hack: if during the scan turns out the OpenSSL binary supports TLS 1.3 would be a better choice
249250
OPENSSL_LOCATION=""
250251
IKNOW_FNAME=false
251252
FIRST_FINDING=true # is this the first finding we are outputting to file?
@@ -275,7 +276,6 @@ KNOWN_OSSL_PROB=false # We need OpenSSL a few times. This vari
275276
DETECTED_TLS_VERSION="" # .. as hex string, e.g. 0300 or 0303
276277
APP_TRAF_KEY_INFO="" # Information about the application traffic keys for a TLS 1.3 connection.
277278
TLS13_ONLY=false # Does the server support TLS 1.3 ONLY?
278-
OSSL_SHORTCUT=${OSSL_SHORTCUT:-false} # Hack: if during the scan turns out the OpenSSL binary supports TLS 1.3 would be a better choice, this enables it.
279279
TLS_EXTENSIONS=""
280280
TLS13_CERT_COMPRESS_METHODS=""
281281
CERTIFICATE_TRANSPARENCY_SOURCE=""
@@ -415,6 +415,7 @@ END_TIME=0 # .. ended
415415
SCAN_TIME=0 # diff of both: total scan time
416416
LAST_TIME=0 # only used for performance measurements (MEASURE_TIME=true)
417417
SERVER_COUNTER=0 # Counter for multiple servers
418+
OPEN_MSG="" # Null the poor man's implementation of a message stack
418419

419420
TLS_LOW_BYTE="" # For "secret" development stuff, see -q below
420421
HEX_CIPHER="" # -- " --
@@ -2405,7 +2406,7 @@ service_detection() {
24052406
;;
24062407
esac
24072408

2408-
outln "\n"
2409+
outln
24092410
tmpfile_handle ${FUNCNAME[0]}.txt
24102411
return 0
24112412
}
@@ -20297,7 +20298,6 @@ find_openssl_binary() {
2029720298
# not check /usr/bin/openssl -- if available. This is more a kludge which we shouldn't use for
2029820299
# every openssl feature. At some point we need to decide which with openssl version we go.
2029920300
# We also check, whether there's /usr/bin/openssl which has TLS 1.3
20300-
OPENSSL2=/usr/bin/openssl
2030120301
if [[ ! "$OSSL_NAME" =~ LibreSSL ]] && [[ ! $OSSL_VER =~ 1.1.1 ]] && [[ ! $OSSL_VER_MAJOR =~ 3 ]]; then
2030220302
if [[ -x $OPENSSL2 ]]; then
2030320303
$OPENSSL2 s_client -help 2>$s_client_has2
@@ -21015,6 +21015,9 @@ EOF
2101521015

2101621016
# arg1: text to display before "-->"
2101721017
# arg2: arg needed to accept to continue
21018+
# ret=0 : arg was accepted to continue (batch mode doesn't do this,or warnings are turned off)
21019+
# 1 : arg was not accepted by user or we're in bacth mode
21020+
2101821021
ignore_no_or_lame() {
2101921022
local a
2102021023

@@ -22033,21 +22036,26 @@ determine_optimal_proto() {
2203322036
[[ $? -ne 0 ]] && exit $ERR_CLUELESS
2203422037
elif "$all_failed" && ! "$ALL_FAILED_SOCKETS"; then
2203522038
if ! "$HAS_TLS13" && "$TLS13_ONLY"; then
22036-
pr_magenta " $NODE:$PORT appears to support TLS 1.3 ONLY. You better use --openssl=<path_to_openssl_supporting_TLS_1.3>"
22037-
if ! "$OSSL_SHORTCUT" || [[ ! -x /usr/bin/openssl ]] || /usr/bin/openssl s_client -tls1_3 2>&1 | grep -aiq "unknown option"; then
22038-
outln
22039-
fileout "$jsonID" "WARN" "$NODE:$PORT appears to support TLS 1.3 ONLY, but $OPENSSL does not support TLS 1.3"
22040-
ignore_no_or_lame " Type \"yes\" to proceed with $OPENSSL and accept all scan problems" "yes"
22041-
[[ $? -ne 0 ]] && exit $ERR_CLUELESS
22042-
MAX_OSSL_FAIL=10
22043-
else
22044-
# dirty hack but an idea for the future to be implemented upfront: Now we know, we'll better off
22045-
# with the OS supplied openssl binary. We need to initialize variables / arrays again though.
22046-
# And the service detection can't be made up for now
22047-
outln ", \n proceeding with /usr/bin/openssl"
22048-
OPENSSL=/usr/bin/openssl
22049-
find_openssl_binary
22050-
prepare_arrays
22039+
if "$OPENSSL2_HAS_TLS_1_3"; then
22040+
if "$OSSL_SHORTCUT" || [[ "$WARNINGS" == batch ]]; then
22041+
# switch w/o asking
22042+
OPEN_MSG=" $NODE:$PORT appeared to support TLS 1.3 ONLY. Thus switched implicitly from\n \"$OPENSSL\" to \"$OPENSSL2\"."
22043+
fileout "$jsonID" "INFO" "$NODE:$PORT appears to support TLS 1.3 ONLY, switching from $OPENSSL to $OPENSSL2 was implicitly enforced"
22044+
OPENSSL="$OPENSSL2"
22045+
find_openssl_binary
22046+
prepare_arrays
22047+
else
22048+
# now we need to ask the user
22049+
ignore_no_or_lame " Type \"yes\" to proceed with \"$OPENSSL2\" OR accept all scan problems" "yes"
22050+
if [[ $? -eq 0 ]]; then
22051+
fileout "$jsonID" "INFO" "$NODE:$PORT appears to support TLS 1.3 ONLY, switching from $OPENSSL to $OPENSSL2 by the user"
22052+
OPENSSL="$OPENSSL2"
22053+
find_openssl_binary
22054+
prepare_arrays
22055+
else
22056+
fileout "$jsonID" "WARN" "$NODE:$PORT appears to support TLS 1.3 ONLY, switching from $OPENSSL to $OPENSSL2 was denied by user"
22057+
fi
22058+
fi
2205122059
fi
2205222060
elif ! "$HAS_SSL3" && [[ "$(has_server_protocol "ssl3")" -eq 0 ]] && [[ "$(has_server_protocol "tls1_3")" -ne 0 ]] && \
2205322061
[[ "$(has_server_protocol "tls1_2")" -ne 0 ]] && [[ "$(has_server_protocol "tls1_1")" -ne 0 ]] &&
@@ -22092,6 +22100,18 @@ determine_optimal_proto() {
2209222100
}
2209322101

2209422102

22103+
# Check messages which needed to be processed. I.e. those which would have destroyed the nice
22104+
# screen output and thus havve been postponed. This is just an idea and is only used once
22105+
# but can be extended in the future. An array might be more handy
22106+
#
22107+
check_msg() {
22108+
if [[ -n "$OPEN_MSG" ]]; then
22109+
outln "$OPEN_MSG"
22110+
OPEN_MSG=""
22111+
fi
22112+
}
22113+
22114+
2209522115
# arg1 (optional): ftp smtp, lmtp, pop3, imap, sieve, xmpp, xmpp-server, telnet, ldap, postgres, mysql, irc, nntp (maybe with trailing s)
2209622116
#
2209722117
determine_service() {
@@ -22132,6 +22152,7 @@ determine_service() {
2213222152
determine_optimal_proto
2213322153
# returns always 0:
2213422154
service_detection $OPTIMAL_PROTO
22155+
check_msg
2213522156
else # STARTTLS
2213622157
if [[ "$1" == postgres ]] || [[ "$1" == sieve ]]; then
2213722158
protocol="$1"

0 commit comments

Comments
 (0)