Skip to content

Commit 9d99a37

Browse files
djelinskiAnthony Scarpino
authored andcommitted
8277881: Missing SessionID in TLS1.3 resumption in compatibility mode
Reviewed-by: ascarpino
1 parent 4669bcd commit 9d99a37

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

src/java.base/share/classes/sun/security/ssl/ClientHello.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -568,15 +568,15 @@ public byte[] produce(ConnectionContext context) throws IOException {
568568
"No new session is allowed and " +
569569
"no existing session can be resumed");
570570
}
571-
572-
if (chc.maximumActiveProtocol.useTLS13PlusSpec() &&
573-
SSLConfiguration.useCompatibilityMode) {
574-
// In compatibility mode, the TLS 1.3 legacy_session_id
575-
// field MUST be non-empty, so a client not offering a
576-
// pre-TLS 1.3 session MUST generate a new 32-byte value.
577-
sessionId =
571+
}
572+
if (sessionId.length() == 0 &&
573+
chc.maximumActiveProtocol.useTLS13PlusSpec() &&
574+
SSLConfiguration.useCompatibilityMode) {
575+
// In compatibility mode, the TLS 1.3 legacy_session_id
576+
// field MUST be non-empty, so a client not offering a
577+
// pre-TLS 1.3 session MUST generate a new 32-byte value.
578+
sessionId =
578579
new SessionId(true, chc.sslContext.getSecureRandom());
579-
}
580580
}
581581

582582
ProtocolVersion minimumVersion = ProtocolVersion.NONE;

src/java.base/share/classes/sun/security/ssl/SSLConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ final class SSLConfiguration implements Cloneable {
9797
static final boolean allowLegacyMasterSecret =
9898
Utilities.getBooleanProperty("jdk.tls.allowLegacyMasterSecret", true);
9999

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

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

Lines changed: 5 additions & 2 deletions
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)