test/jdk/sun/security/ssl/SSLSocketImpl/NoImpactServerRenego.java
changeset 50768 68fa3d4026ea
parent 47216 71c04702a3d5
equal deleted inserted replaced
50767:356eaea05bf0 50768:68fa3d4026ea
    26 
    26 
    27 /*
    27 /*
    28  * @test
    28  * @test
    29  * @bug 7188658
    29  * @bug 7188658
    30  * @summary Add possibility to disable client initiated renegotiation
    30  * @summary Add possibility to disable client initiated renegotiation
    31  * @run main/othervm
    31  * @run main/othervm  -Djdk.tls.rejectClientInitiatedRenegotiation=true
    32  *      -Djdk.tls.rejectClientInitiatedRenegotiation=true NoImpactServerRenego
    32  *      NoImpactServerRenego SSLv3
       
    33  * @run main/othervm  -Djdk.tls.rejectClientInitiatedRenegotiation=true
       
    34  *      NoImpactServerRenego TLSv1
       
    35  * @run main/othervm  -Djdk.tls.rejectClientInitiatedRenegotiation=true
       
    36  *      NoImpactServerRenego TLSv1.1
       
    37  * @run main/othervm  -Djdk.tls.rejectClientInitiatedRenegotiation=true
       
    38  *      NoImpactServerRenego TLSv1.2
    33  */
    39  */
    34 
    40 
    35 import java.io.*;
    41 import java.io.*;
    36 import java.net.*;
    42 import java.net.*;
       
    43 import java.security.Security;
    37 import javax.net.ssl.*;
    44 import javax.net.ssl.*;
    38 
    45 
    39 public class NoImpactServerRenego implements
    46 public class NoImpactServerRenego implements
    40         HandshakeCompletedListener {
    47         HandshakeCompletedListener {
    41 
    48 
   155 
   162 
   156         SSLSocketFactory sslsf =
   163         SSLSocketFactory sslsf =
   157             (SSLSocketFactory) SSLSocketFactory.getDefault();
   164             (SSLSocketFactory) SSLSocketFactory.getDefault();
   158         SSLSocket sslSocket = (SSLSocket)
   165         SSLSocket sslSocket = (SSLSocket)
   159             sslsf.createSocket("localhost", serverPort);
   166             sslsf.createSocket("localhost", serverPort);
       
   167         sslSocket.setEnabledProtocols(new String[] { tlsProtocol });
   160 
   168 
   161         InputStream sslIS = sslSocket.getInputStream();
   169         InputStream sslIS = sslSocket.getInputStream();
   162         OutputStream sslOS = sslSocket.getOutputStream();
   170         OutputStream sslOS = sslSocket.getOutputStream();
   163 
   171 
   164         for (int i = 0; i < 10; i++) {
   172         for (int i = 0; i < 10; i++) {
   184     // use any free port by default
   192     // use any free port by default
   185     volatile int serverPort = 0;
   193     volatile int serverPort = 0;
   186 
   194 
   187     volatile Exception serverException = null;
   195     volatile Exception serverException = null;
   188     volatile Exception clientException = null;
   196     volatile Exception clientException = null;
       
   197 
       
   198     // the specified protocol
       
   199     private static String tlsProtocol;
   189 
   200 
   190     public static void main(String[] args) throws Exception {
   201     public static void main(String[] args) throws Exception {
   191         String keyFilename =
   202         String keyFilename =
   192             System.getProperty("test.src", "./") + "/" + pathToStores +
   203             System.getProperty("test.src", "./") + "/" + pathToStores +
   193                 "/" + keyStoreFile;
   204                 "/" + keyStoreFile;
   198         System.setProperty("javax.net.ssl.keyStore", keyFilename);
   209         System.setProperty("javax.net.ssl.keyStore", keyFilename);
   199         System.setProperty("javax.net.ssl.keyStorePassword", passwd);
   210         System.setProperty("javax.net.ssl.keyStorePassword", passwd);
   200         System.setProperty("javax.net.ssl.trustStore", trustFilename);
   211         System.setProperty("javax.net.ssl.trustStore", trustFilename);
   201         System.setProperty("javax.net.ssl.trustStorePassword", passwd);
   212         System.setProperty("javax.net.ssl.trustStorePassword", passwd);
   202 
   213 
   203         if (debug)
   214         if (debug) {
   204             System.setProperty("javax.net.debug", "all");
   215             System.setProperty("javax.net.debug", "all");
       
   216         }
       
   217 
       
   218         Security.setProperty("jdk.tls.disabledAlgorithms", "");
       
   219 
       
   220         tlsProtocol = args[0];
   205 
   221 
   206         /*
   222         /*
   207          * Start the tests.
   223          * Start the tests.
   208          */
   224          */
   209         new NoImpactServerRenego();
   225         new NoImpactServerRenego();