A couple of minor session resumption fixes JDK-8145252-TLS13-branch
authorapetcher
Fri, 25 May 2018 13:20:01 -0400
branchJDK-8145252-TLS13-branch
changeset 56608 34f33526b9a5
parent 56607 78914bf16bee
child 56609 62d3e1d0be91
A couple of minor session resumption fixes
src/java.base/share/classes/sun/security/ssl/ClientHello.java
src/java.base/share/classes/sun/security/ssl/PreSharedKeyExtension.java
--- a/src/java.base/share/classes/sun/security/ssl/ClientHello.java	Thu May 24 13:09:59 2018 -0700
+++ b/src/java.base/share/classes/sun/security/ssl/ClientHello.java	Fri May 25 13:20:01 2018 -0400
@@ -517,7 +517,10 @@
                     SSLLogger.finest("Try resuming session", session);
                 }
 
-                sessionId = session.getSessionId();
+                // only set session id  if session is 1.2 or earlier
+                if (!session.getProtocolVersion().useTLS13PlusSpec()) {
+                    sessionId = session.getSessionId();
+                }
                 if (!maxProtocolVersion.equals(sessionVersion)) {
                     maxProtocolVersion = sessionVersion;
 
--- a/src/java.base/share/classes/sun/security/ssl/PreSharedKeyExtension.java	Thu May 24 13:09:59 2018 -0700
+++ b/src/java.base/share/classes/sun/security/ssl/PreSharedKeyExtension.java	Fri May 25 13:20:01 2018 -0400
@@ -701,16 +701,13 @@
 
             ClientHandshakeContext chc = (ClientHandshakeContext)context;
 
-            if (!chc.handshakeExtensions.containsKey(SSLExtension.CH_PRE_SHARED_KEY)) {
-                // absence is expected---nothing to do
-                return;
+            if (chc.handshakeExtensions.containsKey(SSLExtension.CH_PRE_SHARED_KEY)) {
+                // The PSK identity should not be reused, even if it is
+                // not selected.
+                chc.resumingSession.consumePskIdentity();
             }
 
-            // The PSK identity should not be reused, even if it is
-            // not selected.
-            chc.resumingSession.consumePskIdentity();
-
-            // If the client requested to resume, the server refused
+            // the server refused to resume, or the client did not request 1.3 resumption
             chc.resumingSession = null;
             chc.isResumption = false;
         }