Skip to content

Commit 43a0099

Browse files
committed
Fix bug when legacy NPN is tested against a TLS 1.3 host
When testing a TLS 1.3 host s_client_options used TLS 1.3 ciphers to test for NPN. As that is not implemented we nee dto make sure any other version is used. This PR ensures that --after testing whether it's a TLS 1.3-only host where this test doesn't make any sense in the first place. Fix for #2633
1 parent 5c1232b commit 43a0099

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

testssl.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11258,6 +11258,12 @@ npn_pre(){
1125811258
fileout "NPN" "WARN" "not tested $OPENSSL doesn't support NPN/SPDY"
1125911259
return 7
1126011260
fi
11261+
if "$TLS13_ONLY"; then
11262+
# https://github.com/openssl/openssl/issues/3665
11263+
pr_warning "There's no such thing as NPN on TLS 1.3-only hosts"
11264+
fileout "NPN" "WARN" "not possible for TLS 1.3-only hosts"
11265+
return 6
11266+
fi
1126111267
return 0
1126211268
}
1126311269

@@ -11281,16 +11287,24 @@ alpn_pre(){
1128111287
run_npn() {
1128211288
local tmpstr
1128311289
local -i ret=0
11290+
local proto=""
1128411291
local jsonID="NPN"
1128511292

1128611293
[[ -n "$STARTTLS" ]] && return 0
1128711294
"$FAST" && return 0
1128811295
pr_bold " NPN/SPDY "
11296+
1128911297
if ! npn_pre; then
1129011298
outln
1129111299
return 0
1129211300
fi
11293-
$OPENSSL s_client $(s_client_options "-connect $NODEIP:$PORT $BUGS $SNI -nextprotoneg "$NPN_PROTOs"") </dev/null 2>$ERRFILE >$TMPFILE
11301+
11302+
# TLS 1.3 s_client doesn't support -nextprotoneg when connecting with TLS 1.3. So we need to make sure it wont be used
11303+
# TLS13_ONLY is tested here again, just to be sure, see npn_pre
11304+
if "$HAS_TLS13" && ! $TLS13_ONLY ]] ; then
11305+
proto="-no_tls1_3"
11306+
fi
11307+
$OPENSSL s_client $(s_client_options "$proto -connect $NODEIP:$PORT $BUGS $SNI -nextprotoneg "$NPN_PROTOs"") </dev/null 2>$ERRFILE >$TMPFILE
1129411308
[[ $? -ne 0 ]] && ret=1
1129511309
tmpstr="$(grep -a '^Protocols' $TMPFILE | sed 's/Protocols.*: //')"
1129611310
if [[ -z "$tmpstr" ]] || [[ "$tmpstr" == " " ]]; then

0 commit comments

Comments
 (0)