No more renegotiation in TLS 1.3 JDK-8145252-TLS13-branch
authorxuelei
Mon, 21 May 2018 09:53:23 -0700
branchJDK-8145252-TLS13-branch
changeset 56585 6425233b7567
parent 56584 a0f3377c58c7
child 56586 e36a1a18817e
No more renegotiation in TLS 1.3
test/jdk/sun/security/ssl/SSLSocketImpl/InvalidateServerSessionRenegotiate.java
test/jdk/sun/security/ssl/SSLSocketImpl/NoImpactServerRenego.java
--- a/test/jdk/sun/security/ssl/SSLSocketImpl/InvalidateServerSessionRenegotiate.java	Mon May 21 08:16:24 2018 -0700
+++ b/test/jdk/sun/security/ssl/SSLSocketImpl/InvalidateServerSessionRenegotiate.java	Mon May 21 09:53:23 2018 -0700
@@ -21,19 +21,25 @@
  * questions.
  */
 
+//
+// SunJSSE does not support dynamic system properties, no way to re-use
+// system properties in samevm/agentvm mode.
+//
+
 /*
  * @test
  * @bug 4403428
  * @summary Invalidating JSSE session on server causes SSLProtocolException
- * @run main/othervm InvalidateServerSessionRenegotiate
- *
- *     SunJSSE does not support dynamic system properties, no way to re-use
- *     system properties in samevm/agentvm mode.
+ * @run main/othervm InvalidateServerSessionRenegotiate SSLv3
+ * @run main/othervm InvalidateServerSessionRenegotiate TLSv1
+ * @run main/othervm InvalidateServerSessionRenegotiate TLSv1.1
+ * @run main/othervm InvalidateServerSessionRenegotiate TLSv1.2
  * @author Brad Wetmore
  */
 
 import java.io.*;
 import java.net.*;
+import java.security.Security;
 import javax.net.ssl.*;
 
 public class InvalidateServerSessionRenegotiate implements
@@ -157,6 +163,7 @@
             (SSLSocketFactory) SSLSocketFactory.getDefault();
         SSLSocket sslSocket = (SSLSocket)
             sslsf.createSocket("localhost", serverPort);
+        sslSocket.setEnabledProtocols(new String[] { tlsProtocol });
 
         InputStream sslIS = sslSocket.getInputStream();
         OutputStream sslOS = sslSocket.getOutputStream();
@@ -187,6 +194,9 @@
     volatile Exception serverException = null;
     volatile Exception clientException = null;
 
+    // the specified protocol
+    private static String tlsProtocol;
+
     public static void main(String[] args) throws Exception {
         String keyFilename =
             System.getProperty("test.src", "./") + "/" + pathToStores +
@@ -200,8 +210,13 @@
         System.setProperty("javax.net.ssl.trustStore", trustFilename);
         System.setProperty("javax.net.ssl.trustStorePassword", passwd);
 
-        if (debug)
+        if (debug) {
             System.setProperty("javax.net.debug", "all");
+        }
+
+        Security.setProperty("jdk.tls.disabledAlgorithms", "");
+
+        tlsProtocol = args[0];
 
         /*
          * Start the tests.
--- a/test/jdk/sun/security/ssl/SSLSocketImpl/NoImpactServerRenego.java	Mon May 21 08:16:24 2018 -0700
+++ b/test/jdk/sun/security/ssl/SSLSocketImpl/NoImpactServerRenego.java	Mon May 21 09:53:23 2018 -0700
@@ -28,12 +28,19 @@
  * @test
  * @bug 7188658
  * @summary Add possibility to disable client initiated renegotiation
- * @run main/othervm
- *      -Djdk.tls.rejectClientInitiatedRenegotiation=true NoImpactServerRenego
+ * @run main/othervm  -Djdk.tls.rejectClientInitiatedRenegotiation=true
+ *      NoImpactServerRenego SSLv3
+ * @run main/othervm  -Djdk.tls.rejectClientInitiatedRenegotiation=true
+ *      NoImpactServerRenego TLSv1
+ * @run main/othervm  -Djdk.tls.rejectClientInitiatedRenegotiation=true
+ *      NoImpactServerRenego TLSv1.1
+ * @run main/othervm  -Djdk.tls.rejectClientInitiatedRenegotiation=true
+ *      NoImpactServerRenego TLSv1.2
  */
 
 import java.io.*;
 import java.net.*;
+import java.security.Security;
 import javax.net.ssl.*;
 
 public class NoImpactServerRenego implements
@@ -157,6 +164,7 @@
             (SSLSocketFactory) SSLSocketFactory.getDefault();
         SSLSocket sslSocket = (SSLSocket)
             sslsf.createSocket("localhost", serverPort);
+        sslSocket.setEnabledProtocols(new String[] { tlsProtocol });
 
         InputStream sslIS = sslSocket.getInputStream();
         OutputStream sslOS = sslSocket.getOutputStream();
@@ -187,6 +195,9 @@
     volatile Exception serverException = null;
     volatile Exception clientException = null;
 
+    // the specified protocol
+    private static String tlsProtocol;
+
     public static void main(String[] args) throws Exception {
         String keyFilename =
             System.getProperty("test.src", "./") + "/" + pathToStores +
@@ -200,8 +211,13 @@
         System.setProperty("javax.net.ssl.trustStore", trustFilename);
         System.setProperty("javax.net.ssl.trustStorePassword", passwd);
 
-        if (debug)
+        if (debug) {
             System.setProperty("javax.net.debug", "all");
+        }
+
+        Security.setProperty("jdk.tls.disabledAlgorithms", "");
+
+        tlsProtocol = args[0];
 
         /*
          * Start the tests.