Skip to content

Commit b94b568

Browse files
lutkerdPaul Hohensee
authored and
Paul Hohensee
committedApr 19, 2023
8277881: Missing SessionID in TLS1.3 resumption in compatibility mode
Backport-of: 9d99a377bfb6ffa890db049aee575e97914fc2a1
1 parent 43561ef commit b94b568

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed
 

‎jdk/src/share/classes/sun/security/ssl/ClientHello.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -495,15 +495,15 @@ public byte[] produce(ConnectionContext context) throws IOException {
495495
"No new session is allowed and " +
496496
"no existing session can be resumed");
497497
}
498-
499-
if (chc.maximumActiveProtocol.useTLS13PlusSpec() &&
500-
SSLConfiguration.useCompatibilityMode) {
501-
// In compatibility mode, the TLS 1.3 legacy_session_id
502-
// field MUST be non-empty, so a client not offering a
503-
// pre-TLS 1.3 session MUST generate a new 32-byte value.
504-
sessionId =
498+
}
499+
if (sessionId.length() == 0 &&
500+
chc.maximumActiveProtocol.useTLS13PlusSpec() &&
501+
SSLConfiguration.useCompatibilityMode) {
502+
// In compatibility mode, the TLS 1.3 legacy_session_id
503+
// field MUST be non-empty, so a client not offering a
504+
// pre-TLS 1.3 session MUST generate a new 32-byte value.
505+
sessionId =
505506
new SessionId(true, chc.sslContext.getSecureRandom());
506-
}
507507
}
508508

509509
ProtocolVersion minimumVersion = ProtocolVersion.NONE;

‎jdk/src/share/classes/sun/security/ssl/SSLConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ final class SSLConfiguration implements Cloneable {
9595
static final boolean allowLegacyMasterSecret =
9696
Utilities.getBooleanProperty("jdk.tls.allowLegacyMasterSecret", true);
9797

98-
// Allow full handshake without Extended Master Secret extension.
98+
// Use TLS1.3 middlebox compatibility mode.
9999
static final boolean useCompatibilityMode = Utilities.getBooleanProperty(
100100
"jdk.tls.client.useCompatibilityMode", true);
101101

‎jdk/test/javax/net/ssl/SSLSession/ResumeTLS13withSNI.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
2626

2727
/*
2828
* @test
29-
* @bug 8211806
29+
* @bug 8211806 8277881
3030
* @summary TLS 1.3 handshake server name indication is missing on a session resume
3131
* @run main/othervm ResumeTLS13withSNI
3232
*/
@@ -338,6 +338,9 @@ private static void checkResumedClientHelloSNI(ByteBuffer resCliHello)
338338

339339
// Get the legacy session length and skip that many bytes
340340
int sessIdLen = Byte.toUnsignedInt(resCliHello.get());
341+
if (sessIdLen == 0) {
342+
throw new Exception("SessionID field empty");
343+
}
341344
resCliHello.position(resCliHello.position() + sessIdLen);
342345

343346
// Skip over all the cipher suites

0 commit comments

Comments
 (0)
Please sign in to comment.