test/jdk/sun/security/ssl/SSLSocketImpl/InvalidateServerSessionRenegotiate.java
branchJDK-8145252-TLS13-branch
changeset 56585 6425233b7567
parent 47216 71c04702a3d5
equal deleted inserted replaced
56584:a0f3377c58c7 56585:6425233b7567
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
       
    24 //
       
    25 // SunJSSE does not support dynamic system properties, no way to re-use
       
    26 // system properties in samevm/agentvm mode.
       
    27 //
       
    28 
    24 /*
    29 /*
    25  * @test
    30  * @test
    26  * @bug 4403428
    31  * @bug 4403428
    27  * @summary Invalidating JSSE session on server causes SSLProtocolException
    32  * @summary Invalidating JSSE session on server causes SSLProtocolException
    28  * @run main/othervm InvalidateServerSessionRenegotiate
    33  * @run main/othervm InvalidateServerSessionRenegotiate SSLv3
    29  *
    34  * @run main/othervm InvalidateServerSessionRenegotiate TLSv1
    30  *     SunJSSE does not support dynamic system properties, no way to re-use
    35  * @run main/othervm InvalidateServerSessionRenegotiate TLSv1.1
    31  *     system properties in samevm/agentvm mode.
    36  * @run main/othervm InvalidateServerSessionRenegotiate TLSv1.2
    32  * @author Brad Wetmore
    37  * @author Brad Wetmore
    33  */
    38  */
    34 
    39 
    35 import java.io.*;
    40 import java.io.*;
    36 import java.net.*;
    41 import java.net.*;
       
    42 import java.security.Security;
    37 import javax.net.ssl.*;
    43 import javax.net.ssl.*;
    38 
    44 
    39 public class InvalidateServerSessionRenegotiate implements
    45 public class InvalidateServerSessionRenegotiate implements
    40         HandshakeCompletedListener {
    46         HandshakeCompletedListener {
    41 
    47 
   155 
   161 
   156         SSLSocketFactory sslsf =
   162         SSLSocketFactory sslsf =
   157             (SSLSocketFactory) SSLSocketFactory.getDefault();
   163             (SSLSocketFactory) SSLSocketFactory.getDefault();
   158         SSLSocket sslSocket = (SSLSocket)
   164         SSLSocket sslSocket = (SSLSocket)
   159             sslsf.createSocket("localhost", serverPort);
   165             sslsf.createSocket("localhost", serverPort);
       
   166         sslSocket.setEnabledProtocols(new String[] { tlsProtocol });
   160 
   167 
   161         InputStream sslIS = sslSocket.getInputStream();
   168         InputStream sslIS = sslSocket.getInputStream();
   162         OutputStream sslOS = sslSocket.getOutputStream();
   169         OutputStream sslOS = sslSocket.getOutputStream();
   163 
   170 
   164         for (int i = 0; i < 10; i++) {
   171         for (int i = 0; i < 10; i++) {
   184     // use any free port by default
   191     // use any free port by default
   185     volatile int serverPort = 0;
   192     volatile int serverPort = 0;
   186 
   193 
   187     volatile Exception serverException = null;
   194     volatile Exception serverException = null;
   188     volatile Exception clientException = null;
   195     volatile Exception clientException = null;
       
   196 
       
   197     // the specified protocol
       
   198     private static String tlsProtocol;
   189 
   199 
   190     public static void main(String[] args) throws Exception {
   200     public static void main(String[] args) throws Exception {
   191         String keyFilename =
   201         String keyFilename =
   192             System.getProperty("test.src", "./") + "/" + pathToStores +
   202             System.getProperty("test.src", "./") + "/" + pathToStores +
   193                 "/" + keyStoreFile;
   203                 "/" + keyStoreFile;
   198         System.setProperty("javax.net.ssl.keyStore", keyFilename);
   208         System.setProperty("javax.net.ssl.keyStore", keyFilename);
   199         System.setProperty("javax.net.ssl.keyStorePassword", passwd);
   209         System.setProperty("javax.net.ssl.keyStorePassword", passwd);
   200         System.setProperty("javax.net.ssl.trustStore", trustFilename);
   210         System.setProperty("javax.net.ssl.trustStore", trustFilename);
   201         System.setProperty("javax.net.ssl.trustStorePassword", passwd);
   211         System.setProperty("javax.net.ssl.trustStorePassword", passwd);
   202 
   212 
   203         if (debug)
   213         if (debug) {
   204             System.setProperty("javax.net.debug", "all");
   214             System.setProperty("javax.net.debug", "all");
       
   215         }
       
   216 
       
   217         Security.setProperty("jdk.tls.disabledAlgorithms", "");
       
   218 
       
   219         tlsProtocol = args[0];
   205 
   220 
   206         /*
   221         /*
   207          * Start the tests.
   222          * Start the tests.
   208          */
   223          */
   209         new InvalidateServerSessionRenegotiate();
   224         new InvalidateServerSessionRenegotiate();