test correction, reject renegotiation applies to TLS 1.2 and prior versions only JDK-8145252-TLS13-branch
authorxuelei
Tue, 15 May 2018 14:52:51 -0700
branchJDK-8145252-TLS13-branch
changeset 56560 1753f2461f71
parent 56559 a423173d0578
child 56561 5f23e0400f27
test correction, reject renegotiation applies to TLS 1.2 and prior versions only
test/jdk/sun/security/ssl/SSLSocketImpl/RejectClientRenego.java
--- a/test/jdk/sun/security/ssl/SSLSocketImpl/RejectClientRenego.java	Tue May 15 13:01:37 2018 -0700
+++ b/test/jdk/sun/security/ssl/SSLSocketImpl/RejectClientRenego.java	Tue May 15 14:52:51 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,12 +28,19 @@
  * @test
  * @bug 7188658
  * @summary Add possibility to disable client initiated renegotiation
- * @run main/othervm RejectClientRenego true
- * @run main/othervm RejectClientRenego false
+ * @run main/othervm RejectClientRenego true SSLv3
+ * @run main/othervm RejectClientRenego false SSLv3
+ * @run main/othervm RejectClientRenego true TLSv1
+ * @run main/othervm RejectClientRenego false TLSv1
+ * @run main/othervm RejectClientRenego true TLSv1.1
+ * @run main/othervm RejectClientRenego false TLSv1.1
+ * @run main/othervm RejectClientRenego true TLSv1.2
+ * @run main/othervm RejectClientRenego false TLSv1.2
  */
 
 import java.io.*;
 import java.net.*;
+import java.security.Security;
 import javax.net.ssl.*;
 
 public class RejectClientRenego implements
@@ -113,6 +120,7 @@
         serverReady = true;
 
         SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
+        sslSocket.setEnabledProtocols(new String[] { tlsProtocol });
         sslSocket.addHandshakeCompletedListener(this);
         InputStream sslIS = sslSocket.getInputStream();
         OutputStream sslOS = sslSocket.getOutputStream();
@@ -157,6 +165,7 @@
             (SSLSocketFactory) SSLSocketFactory.getDefault();
         SSLSocket sslSocket = (SSLSocket)
             sslsf.createSocket("localhost", serverPort);
+        sslSocket.setEnabledProtocols(new String[] { tlsProtocol });
 
         InputStream sslIS = sslSocket.getInputStream();
         OutputStream sslOS = sslSocket.getOutputStream();
@@ -202,6 +211,9 @@
     // Is it abbreviated handshake?
     private static boolean isAbbreviated = false;
 
+    // the specified protocol
+    private static String tlsProtocol;
+
     public static void main(String[] args) throws Exception {
         String keyFilename =
             System.getProperty("test.src", "./") + "/" + pathToStores +
@@ -219,14 +231,19 @@
         System.setProperty(
             "jdk.tls.rejectClientInitiatedRenegotiation", "true");
 
-        if (debug)
+        if (debug) {
             System.setProperty("javax.net.debug", "all");
+        }
+
+        Security.setProperty("jdk.tls.disabledAlgorithms", "");
 
         // Is it abbreviated handshake?
         if ("true".equals(args[0])) {
             isAbbreviated = true;
         }
 
+        tlsProtocol = args[1];
+
         /*
          * Start the tests.
          */