test/jdk/sun/security/tools/keytool/PrintSSL.java
branchJDK-8145252-TLS13-branch
changeset 56542 56aaa6cb3693
parent 47216 71c04702a3d5
equal deleted inserted replaced
56541:92cbbfc996f3 56542:56aaa6cb3693
    51         Files.deleteIfExists(Paths.get("keystore"));
    51         Files.deleteIfExists(Paths.get("keystore"));
    52 
    52 
    53         // make sure that "-printcert" works with weak algorithms
    53         // make sure that "-printcert" works with weak algorithms
    54         OutputAnalyzer out = SecurityTools.keytool("-genkeypair "
    54         OutputAnalyzer out = SecurityTools.keytool("-genkeypair "
    55                 + "-keystore keystore -storepass passphrase "
    55                 + "-keystore keystore -storepass passphrase "
    56                 + "-keypass passphrase -keyalg rsa -keysize 512 "
    56                 + "-keypass passphrase -keyalg rsa -keysize 1024 "
    57                 + "-sigalg MD5withRSA -alias rsa_alias -dname CN=Server");
    57                 + "-sigalg MD5withRSA -alias rsa_alias -dname CN=Server");
    58         System.out.println(out.getOutput());
    58         System.out.println(out.getOutput());
    59         out.shouldHaveExitValue(0);
    59         out.shouldHaveExitValue(0);
    60 
    60 
    61         int port = new Server().start();
    61         int port = new Server().start();
    90         public void run() {
    90         public void run() {
    91 
    91 
    92             System.setProperty("javax.net.ssl.keyStorePassword", "passphrase");
    92             System.setProperty("javax.net.ssl.keyStorePassword", "passphrase");
    93             System.setProperty("javax.net.ssl.keyStore", "keystore");
    93             System.setProperty("javax.net.ssl.keyStore", "keystore");
    94             SSLServerSocketFactory sslssf =
    94             SSLServerSocketFactory sslssf =
    95                     (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
    95                 (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
    96             try (ServerSocket server = sslssf.createServerSocket(0)) {
    96             try (ServerSocket server = sslssf.createServerSocket(0)) {
    97                 this.serverPort = server.getLocalPort();
    97                 this.serverPort = server.getLocalPort();
    98                 System.out.printf("%nServer started on: %s%n", getServerPort());
    98                 System.out.printf("%nServer started on: %s%n", getServerPort());
    99                 untilServerReady.countDown();
    99                 untilServerReady.countDown();
   100                 ((SSLSocket)server.accept()).startHandshake();
   100                 ((SSLSocket)server.accept()).startHandshake();
   108         public int getServerPort() {
   108         public int getServerPort() {
   109             return this.serverPort;
   109             return this.serverPort;
   110         }
   110         }
   111 
   111 
   112     }
   112     }
       
   113 }
   113 
   114 
   114 }