Skip to content

Commit e69a29c

Browse files
authored
Merge pull request #2637 from testssl/fix_2633_3.0
Fix bug when legacy NPN is tested against a TLS 1.3 host
2 parents 439937f + 7597360 commit e69a29c

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
@@ -10127,6 +10127,12 @@ npn_pre(){
1012710127
fileout "NPN" "WARN" "not tested $OPENSSL doesn't support NPN/SPDY"
1012810128
return 7
1012910129
fi
10130+
if "$TLS13_ONLY"; then
10131+
# https://github.com/openssl/openssl/issues/3665
10132+
pr_warning "There's no such thing as NPN on TLS 1.3-only hosts"
10133+
fileout "NPN" "WARN" "not possible for TLS 1.3-only hosts"
10134+
return 6
10135+
fi
1013010136
return 0
1013110137
}
1013210138

@@ -10150,16 +10156,24 @@ alpn_pre(){
1015010156
run_npn() {
1015110157
local tmpstr
1015210158
local -i ret=0
10159+
local proto=""
1015310160
local jsonID="NPN"
1015410161

1015510162
[[ -n "$STARTTLS" ]] && return 0
1015610163
"$FAST" && return 0
1015710164
pr_bold " NPN/SPDY "
10165+
1015810166
if ! npn_pre; then
1015910167
outln
1016010168
return 0
1016110169
fi
10162-
$OPENSSL s_client $(s_client_options "-connect $NODEIP:$PORT $BUGS $SNI -nextprotoneg "$NPN_PROTOs"") </dev/null 2>$ERRFILE >$TMPFILE
10170+
10171+
# TLS 1.3 s_client doesn't support -nextprotoneg when connecting with TLS 1.3. So we need to make sure it won't be used
10172+
# TLS13_ONLY is tested here again, just to be sure, see npn_pre
10173+
if "$HAS_TLS13" && ! $TLS13_ONLY ]] ; then
10174+
proto="-no_tls1_3"
10175+
fi
10176+
$OPENSSL s_client $(s_client_options "$proto -connect $NODEIP:$PORT $BUGS $SNI -nextprotoneg "$NPN_PROTOs"") </dev/null 2>$ERRFILE >$TMPFILE
1016310177
[[ $? -ne 0 ]] && ret=1
1016410178
tmpstr="$(grep -a '^Protocols' $TMPFILE | sed 's/Protocols.*: //')"
1016510179
if [[ -z "$tmpstr" ]] || [[ "$tmpstr" == " " ]]; then

0 commit comments

Comments
 (0)