TLS 1.3, correct a serious ALPN impl typo JDK-8145252-TLS13-branch
authorxuelei
Wed, 16 May 2018 22:13:16 -0700
branchJDK-8145252-TLS13-branch
changeset 56567 45e123c0de3b
parent 56566 a06a7dece503
child 56568 7fe8ce3c78b6
TLS 1.3, correct a serious ALPN impl typo
src/java.base/share/classes/sun/security/ssl/AlpnExtension.java
--- a/src/java.base/share/classes/sun/security/ssl/AlpnExtension.java	Wed May 16 21:18:06 2018 -0700
+++ b/src/java.base/share/classes/sun/security/ssl/AlpnExtension.java	Wed May 16 22:13:16 2018 -0700
@@ -445,7 +445,9 @@
             // In response to ALPN request only
             AlpnSpec requestedAlps =
                     (AlpnSpec)chc.handshakeExtensions.get(SSLExtension.CH_ALPN);
-            if (requestedAlps == null) {
+            if (requestedAlps == null ||
+                    requestedAlps.applicationProtocols == null ||
+                    requestedAlps.applicationProtocols.isEmpty()) {
                 chc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
                     "Unexpected " + SSLExtension.CH_ALPN.name + " extension");
             }
@@ -468,7 +470,7 @@
             }
             
             // The respond application protocol must be one of the requested.
-            if (requestedAlps.applicationProtocols.contains(
+            if (!requestedAlps.applicationProtocols.containsAll(
                     spec.applicationProtocols)) {
                 chc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
                     "Invalid " + SSLExtension.CH_ALPN.name + " extension: " +