test/jdk/javax/net/ssl/templates/SSLSocketTemplate.java
author wetmore
Fri, 11 May 2018 15:53:12 -0700
branchJDK-8145252-TLS13-branch
changeset 56542 56aaa6cb3693
parent 47216 71c04702a3d5
child 56570 60ff67126765
permissions -rw-r--r--
Initial TLSv1.3 Implementation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
     1
/*
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
     2
 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
     4
 *
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
     7
 * published by the Free Software Foundation.
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
     8
 *
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
    13
 * accompanied this code).
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
    14
 *
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
    18
 *
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
    21
 * questions.
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
    22
 */
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
    23
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    24
//
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    25
// Please run in othervm mode.  SunJSSE does not support dynamic system
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    26
// properties, no way to re-use system properties in samevm/agentvm mode.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    27
//
42155
c9b28ab5297b 8168969: Merge SSLSocketSample and SSLSocketTemplate
asmotrak
parents: 41595
diff changeset
    28
c9b28ab5297b 8168969: Merge SSLSocketSample and SSLSocketTemplate
asmotrak
parents: 41595
diff changeset
    29
/*
c9b28ab5297b 8168969: Merge SSLSocketSample and SSLSocketTemplate
asmotrak
parents: 41595
diff changeset
    30
 * @test
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    31
 * @bug 8161106 8170329
43335
911fcebb04d2 8173478: SSL related tests failes with message: "java.security.NoSuchAlgorithmException: EC KeyFactory not available"
skovalev
parents: 42920
diff changeset
    32
 * @modules jdk.crypto.ec
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    33
 * @summary Improve SSLSocket test template
42155
c9b28ab5297b 8168969: Merge SSLSocketSample and SSLSocketTemplate
asmotrak
parents: 41595
diff changeset
    34
 * @run main/othervm SSLSocketTemplate
c9b28ab5297b 8168969: Merge SSLSocketSample and SSLSocketTemplate
asmotrak
parents: 41595
diff changeset
    35
 */
43335
911fcebb04d2 8173478: SSL related tests failes with message: "java.security.NoSuchAlgorithmException: EC KeyFactory not available"
skovalev
parents: 42920
diff changeset
    36
911fcebb04d2 8173478: SSL related tests failes with message: "java.security.NoSuchAlgorithmException: EC KeyFactory not available"
skovalev
parents: 42920
diff changeset
    37
import java.io.ByteArrayInputStream;
911fcebb04d2 8173478: SSL related tests failes with message: "java.security.NoSuchAlgorithmException: EC KeyFactory not available"
skovalev
parents: 42920
diff changeset
    38
import java.io.InputStream;
911fcebb04d2 8173478: SSL related tests failes with message: "java.security.NoSuchAlgorithmException: EC KeyFactory not available"
skovalev
parents: 42920
diff changeset
    39
import java.io.IOException;
911fcebb04d2 8173478: SSL related tests failes with message: "java.security.NoSuchAlgorithmException: EC KeyFactory not available"
skovalev
parents: 42920
diff changeset
    40
import java.io.OutputStream;
911fcebb04d2 8173478: SSL related tests failes with message: "java.security.NoSuchAlgorithmException: EC KeyFactory not available"
skovalev
parents: 42920
diff changeset
    41
import javax.net.ssl.KeyManagerFactory;
911fcebb04d2 8173478: SSL related tests failes with message: "java.security.NoSuchAlgorithmException: EC KeyFactory not available"
skovalev
parents: 42920
diff changeset
    42
import javax.net.ssl.SSLContext;
911fcebb04d2 8173478: SSL related tests failes with message: "java.security.NoSuchAlgorithmException: EC KeyFactory not available"
skovalev
parents: 42920
diff changeset
    43
import javax.net.ssl.SSLServerSocket;
911fcebb04d2 8173478: SSL related tests failes with message: "java.security.NoSuchAlgorithmException: EC KeyFactory not available"
skovalev
parents: 42920
diff changeset
    44
import javax.net.ssl.SSLServerSocketFactory;
911fcebb04d2 8173478: SSL related tests failes with message: "java.security.NoSuchAlgorithmException: EC KeyFactory not available"
skovalev
parents: 42920
diff changeset
    45
import javax.net.ssl.SSLSocket;
911fcebb04d2 8173478: SSL related tests failes with message: "java.security.NoSuchAlgorithmException: EC KeyFactory not available"
skovalev
parents: 42920
diff changeset
    46
import javax.net.ssl.SSLSocketFactory;
911fcebb04d2 8173478: SSL related tests failes with message: "java.security.NoSuchAlgorithmException: EC KeyFactory not available"
skovalev
parents: 42920
diff changeset
    47
import javax.net.ssl.TrustManagerFactory;
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    48
import java.net.InetSocketAddress;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    49
import java.net.SocketTimeoutException;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    50
import java.security.KeyStore;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    51
import java.security.PrivateKey;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    52
import java.security.KeyFactory;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    53
import java.security.cert.Certificate;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    54
import java.security.cert.CertificateFactory;
43335
911fcebb04d2 8173478: SSL related tests failes with message: "java.security.NoSuchAlgorithmException: EC KeyFactory not available"
skovalev
parents: 42920
diff changeset
    55
import java.security.spec.PKCS8EncodedKeySpec;
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    56
import java.util.Base64;
42155
c9b28ab5297b 8168969: Merge SSLSocketSample and SSLSocketTemplate
asmotrak
parents: 41595
diff changeset
    57
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    58
import java.util.concurrent.CountDownLatch;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    59
import java.util.concurrent.TimeUnit;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    60
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    61
/**
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    62
 * Template to help speed your client/server tests.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    63
 *
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    64
 * Two examples that use this template:
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    65
 *    test/sun/security/ssl/ServerHandshaker/AnonCipherWithWantClientAuth.java
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    66
 *    test/sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    67
 */
42155
c9b28ab5297b 8168969: Merge SSLSocketSample and SSLSocketTemplate
asmotrak
parents: 41595
diff changeset
    68
public class SSLSocketTemplate {
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
    69
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    70
    /*
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    71
     * ==================
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    72
     * Run the test case.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    73
     */
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    74
    public static void main(String[] args) throws Exception {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    75
        (new SSLSocketTemplate()).run();
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    76
    }
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    77
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    78
    /*
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    79
     * Run the test case.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    80
     */
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    81
    public void run() throws Exception {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    82
        bootup();
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    83
    }
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    84
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    85
    /*
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    86
     * Define the server side application of the test for the specified socket.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    87
     */
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    88
    protected void runServerApplication(SSLSocket socket) throws Exception {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    89
        // here comes the test logic
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    90
        InputStream sslIS = socket.getInputStream();
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    91
        OutputStream sslOS = socket.getOutputStream();
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    92
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    93
        sslIS.read();
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    94
        sslOS.write(85);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    95
        sslOS.flush();
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    96
    }
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    97
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    98
    /*
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
    99
     * Define the client side application of the test for the specified socket.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   100
     * This method is used if the returned value of
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   101
     * isCustomizedClientConnection() is false.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   102
     *
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   103
     * @param socket may be null is no client socket is generated.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   104
     *
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   105
     * @see #isCustomizedClientConnection()
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   106
     */
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   107
    protected void runClientApplication(SSLSocket socket) throws Exception {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   108
        InputStream sslIS = socket.getInputStream();
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   109
        OutputStream sslOS = socket.getOutputStream();
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   110
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   111
        sslOS.write(280);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   112
        sslOS.flush();
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   113
        sslIS.read();
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   114
    }
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   115
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   116
    /*
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   117
     * Define the client side application of the test for the specified
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   118
     * server port.  This method is used if the returned value of
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   119
     * isCustomizedClientConnection() is true.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   120
     *
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   121
     * Note that the client need to connect to the server port by itself
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   122
     * for the actual message exchange.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   123
     *
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   124
     * @see #isCustomizedClientConnection()
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   125
     */
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   126
    protected void runClientApplication(int serverPort) throws Exception {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   127
        // blank
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   128
    }
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   129
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   130
    /*
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   131
     * Create an instance of SSLContext for client use.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   132
     */
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   133
    protected SSLContext createClientSSLContext() throws Exception {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   134
        return createSSLContext(trustedCertStrs,
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   135
                endEntityCertStrs, endEntityPrivateKeys,
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   136
                endEntityPrivateKeyAlgs,
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   137
                endEntityPrivateKeyNames,
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   138
                getClientContextParameters());
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   139
    }
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   140
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   141
    /*
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   142
     * Create an instance of SSLContext for server use.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   143
     */
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   144
    protected SSLContext createServerSSLContext() throws Exception {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   145
        return createSSLContext(trustedCertStrs,
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   146
                endEntityCertStrs, endEntityPrivateKeys,
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   147
                endEntityPrivateKeyAlgs,
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   148
                endEntityPrivateKeyNames,
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   149
                getServerContextParameters());
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   150
    }
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   151
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   152
    /*
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   153
     * The parameters used to configure SSLContext.
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   154
     */
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   155
    protected static final class ContextParameters {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   156
        final String contextProtocol;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   157
        final String tmAlgorithm;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   158
        final String kmAlgorithm;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   159
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   160
        ContextParameters(String contextProtocol,
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   161
                String tmAlgorithm, String kmAlgorithm) {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   162
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   163
            this.contextProtocol = contextProtocol;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   164
            this.tmAlgorithm = tmAlgorithm;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   165
            this.kmAlgorithm = kmAlgorithm;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   166
        }
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   167
    }
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   168
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   169
    /*
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   170
     * Get the client side parameters of SSLContext.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   171
     */
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   172
    protected ContextParameters getClientContextParameters() {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   173
        return new ContextParameters("TLS", "PKIX", "NewSunX509");
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   174
    }
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   175
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   176
    /*
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   177
     * Get the server side parameters of SSLContext.
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   178
     */
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   179
    protected ContextParameters getServerContextParameters() {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   180
        return new ContextParameters("TLS", "PKIX", "NewSunX509");
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   181
    }
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   182
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   183
    /*
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   184
     * Does the client side use customized connection other than
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   185
     * explicit Socket.connect(), for example, URL.openConnection()?
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   186
     */
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   187
    protected boolean isCustomizedClientConnection() {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   188
        return false;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   189
    }
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   190
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   191
    /*
42920
781f5e69910b 8168935: sun/security/ssl/SSLContextImpl/TrustTrustedCert.java failed Intermittently
mli
parents: 42464
diff changeset
   192
     * Configure the server side socket.
781f5e69910b 8168935: sun/security/ssl/SSLContextImpl/TrustTrustedCert.java failed Intermittently
mli
parents: 42464
diff changeset
   193
     */
781f5e69910b 8168935: sun/security/ssl/SSLContextImpl/TrustTrustedCert.java failed Intermittently
mli
parents: 42464
diff changeset
   194
    protected void configureServerSocket(SSLServerSocket socket) {
781f5e69910b 8168935: sun/security/ssl/SSLContextImpl/TrustTrustedCert.java failed Intermittently
mli
parents: 42464
diff changeset
   195
781f5e69910b 8168935: sun/security/ssl/SSLContextImpl/TrustTrustedCert.java failed Intermittently
mli
parents: 42464
diff changeset
   196
    }
781f5e69910b 8168935: sun/security/ssl/SSLContextImpl/TrustTrustedCert.java failed Intermittently
mli
parents: 42464
diff changeset
   197
781f5e69910b 8168935: sun/security/ssl/SSLContextImpl/TrustTrustedCert.java failed Intermittently
mli
parents: 42464
diff changeset
   198
    /*
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   199
     * =============================================
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   200
     * Define the client and server side operations.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   201
     *
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   202
     * If the client or server is doing some kind of object creation
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   203
     * that the other side depends on, and that thread prematurely
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   204
     * exits, you may experience a hang.  The test harness will
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   205
     * terminate all hung threads after its timeout has expired,
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   206
     * currently 3 minutes by default, but you might try to be
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   207
     * smart about it....
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   208
     */
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   209
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   210
    /*
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   211
     * Is the server ready to serve?
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   212
     */
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   213
    private final CountDownLatch serverCondition = new CountDownLatch(1);
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   214
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   215
    /*
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   216
     * Is the client ready to handshake?
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   217
     */
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   218
    private final CountDownLatch clientCondition = new CountDownLatch(1);
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   219
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   220
    /*
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   221
     * What's the server port?  Use any free port by default
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   222
     */
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   223
    private volatile int serverPort = 0;
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   224
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   225
    /*
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   226
     * Define the server side of the test.
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   227
     */
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   228
    private void doServerSide() throws Exception {
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   229
        // kick start the server side service
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   230
        SSLContext context = createServerSSLContext();
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   231
        SSLServerSocketFactory sslssf = context.getServerSocketFactory();
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   232
        SSLServerSocket sslServerSocket =
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   233
                (SSLServerSocket)sslssf.createServerSocket(serverPort);
42920
781f5e69910b 8168935: sun/security/ssl/SSLContextImpl/TrustTrustedCert.java failed Intermittently
mli
parents: 42464
diff changeset
   234
        configureServerSocket(sslServerSocket);
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   235
        serverPort = sslServerSocket.getLocalPort();
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   236
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   237
        // Signal the client, the server is ready to accept connection.
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   238
        serverCondition.countDown();
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   239
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   240
        // Try to accept a connection in 30 seconds.
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   241
        SSLSocket sslSocket;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   242
        try {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   243
            sslServerSocket.setSoTimeout(30000);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   244
            sslSocket = (SSLSocket)sslServerSocket.accept();
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   245
        } catch (SocketTimeoutException ste) {
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   246
            // Ignore the test case if no connection within 30 seconds.
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   247
            System.out.println(
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   248
                "No incoming client connection in 30 seconds. " +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   249
                "Ignore in server side.");
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   250
            return;
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   251
        } finally {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   252
            sslServerSocket.close();
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   253
        }
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   254
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   255
        // handle the connection
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   256
        try {
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   257
            // Is it the expected client connection?
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   258
            //
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   259
            // Naughty test cases or third party routines may try to
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   260
            // connection to this server port unintentionally.  In
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   261
            // order to mitigate the impact of unexpected client
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   262
            // connections and avoid intermittent failure, it should
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   263
            // be checked that the accepted connection is really linked
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   264
            // to the expected client.
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   265
            boolean clientIsReady =
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   266
                    clientCondition.await(30L, TimeUnit.SECONDS);
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   267
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   268
            if (clientIsReady) {
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   269
                // Run the application in server side.
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   270
                runServerApplication(sslSocket);
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   271
            } else {    // Otherwise, ignore
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   272
                // We don't actually care about plain socket connections
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   273
                // for TLS communication testing generally.  Just ignore
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   274
                // the test if the accepted connection is not linked to
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   275
                // the expected client or the client connection timeout
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   276
                // in 30 seconds.
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   277
                System.out.println(
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   278
                        "The client is not the expected one or timeout. " +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   279
                        "Ignore in server side.");
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   280
            }
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   281
        } finally {
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   282
            sslSocket.close();
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   283
        }
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   284
    }
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   285
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   286
    /*
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   287
     * Define the client side of the test.
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   288
     */
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   289
    private void doClientSide() throws Exception {
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   290
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   291
        // Wait for server to get started.
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   292
        //
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   293
        // The server side takes care of the issue if the server cannot
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   294
        // get started in 90 seconds.  The client side would just ignore
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   295
        // the test case if the serer is not ready.
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   296
        boolean serverIsReady =
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   297
                serverCondition.await(90L, TimeUnit.SECONDS);
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   298
        if (!serverIsReady) {
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   299
            System.out.println(
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   300
                    "The server is not ready yet in 90 seconds. " +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   301
                    "Ignore in client side.");
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   302
            return;
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   303
        }
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   304
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   305
        if (isCustomizedClientConnection()) {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   306
            // Signal the server, the client is ready to communicate.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   307
            clientCondition.countDown();
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   308
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   309
            // Run the application in client side.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   310
            runClientApplication(serverPort);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   311
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   312
            return;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   313
        }
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   314
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   315
        SSLContext context = createClientSSLContext();
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   316
        SSLSocketFactory sslsf = context.getSocketFactory();
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   317
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   318
        try (SSLSocket sslSocket = (SSLSocket)sslsf.createSocket()) {
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   319
            try {
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   320
                sslSocket.connect(
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   321
                        new InetSocketAddress("localhost", serverPort), 15000);
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   322
            } catch (IOException ioe) {
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   323
                // The server side may be impacted by naughty test cases or
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   324
                // third party routines, and cannot accept connections.
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   325
                //
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   326
                // Just ignore the test if the connection cannot be
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   327
                // established.
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   328
                System.out.println(
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   329
                        "Cannot make a connection in 15 seconds. " +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   330
                        "Ignore in client side.");
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   331
                return;
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   332
            }
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   333
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   334
            // OK, here the client and server get connected.
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   335
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   336
            // Signal the server, the client is ready to communicate.
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   337
            clientCondition.countDown();
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   338
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   339
            // There is still a chance in theory that the server thread may
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   340
            // wait client-ready timeout and then quit.  The chance should
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   341
            // be really rare so we don't consider it until it becomes a
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   342
            // real problem.
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   343
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   344
            // Run the application in client side.
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   345
            runClientApplication(sslSocket);
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   346
        }
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   347
    }
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   348
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   349
    /*
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   350
     * =============================================
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   351
     * Stuffs to customize the SSLContext instances.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   352
     */
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   353
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   354
    /*
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   355
     * =======================================
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   356
     * Certificates and keys used in the test.
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   357
     */
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   358
    // Trusted certificates.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   359
    private final static String[] trustedCertStrs = {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   360
        // SHA256withECDSA, curve prime256v1
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   361
        // Validity
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   362
        //    Not Before: Nov 25 04:19:51 2016 GMT
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   363
        //    Not After : Nov  5 04:19:51 2037 GMT
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   364
        // Subject Key Identifier:
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   365
        //    CA:48:E8:00:C1:42:BD:59:9B:79:D9:B4:B4:CE:3F:68:0C:C8:C4:0C
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   366
        "-----BEGIN CERTIFICATE-----\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   367
        "MIICHDCCAcGgAwIBAgIJAJtKs6ZEcVjxMAoGCCqGSM49BAMCMDsxCzAJBgNVBAYT\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   368
        "AlVTMQ0wCwYDVQQKEwRKYXZhMR0wGwYDVQQLExRTdW5KU1NFIFRlc3QgU2VyaXZj\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   369
        "ZTAeFw0xNjExMjUwNDE5NTFaFw0zNzExMDUwNDE5NTFaMDsxCzAJBgNVBAYTAlVT\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   370
        "MQ0wCwYDVQQKEwRKYXZhMR0wGwYDVQQLExRTdW5KU1NFIFRlc3QgU2VyaXZjZTBZ\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   371
        "MBMGByqGSM49AgEGCCqGSM49AwEHA0IABKMO/AFDHZia65RaqMIBX7WBdtzFj8fz\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   372
        "ggqMADLJhoszS6qfTUDYskETw3uHfB3KAOENsoKX446qFFPuVjxS1aejga0wgaow\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   373
        "HQYDVR0OBBYEFMpI6ADBQr1Zm3nZtLTOP2gMyMQMMGsGA1UdIwRkMGKAFMpI6ADB\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   374
        "Qr1Zm3nZtLTOP2gMyMQMoT+kPTA7MQswCQYDVQQGEwJVUzENMAsGA1UEChMESmF2\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   375
        "YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2WCCQCbSrOmRHFY8TAPBgNV\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   376
        "HRMBAf8EBTADAQH/MAsGA1UdDwQEAwIBBjAKBggqhkjOPQQDAgNJADBGAiEA5cJ/\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   377
        "jirBbXxzpZ6kdp/Zb/yrIBnr4jiPGJTLgRTb8s4CIQChUDfP1Zqg0qJVfqFNaL4V\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   378
        "a0EAeJHXGZnvCGGqHzoxkg==\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   379
        "-----END CERTIFICATE-----",
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   380
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   381
        // SHA256withRSA, 2048 bits
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   382
        // Validity
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   383
        //     Not Before: Apr 12 06:51:49 2018 GMT
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   384
        //     Not After : Apr  7 06:51:49 2038 GMT
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   385
        // Subject Key Identifier:
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   386
        //     14:AE:A5:A9:2C:0F:E3:25:BA:1B:AD:B6:A7:DB:07:F0:4D:14:49:97
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   387
        "-----BEGIN CERTIFICATE-----\n" +
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   388
        "MIIDTDCCAjSgAwIBAgIJALzz9cKBmONRMA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNV\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   389
        "BAYTAlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2Vy\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   390
        "aXZjZTAeFw0xODA0MTIwNjUxNDlaFw0zODA0MDcwNjUxNDlaMDsxCzAJBgNVBAYT\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   391
        "AlVTMQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZj\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   392
        "ZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANPfPtImftkV2UAB+QPa\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   393
        "R9udeRxApNphb+70T1p3GFql8sUG6/Rbao5H1QllzZ22+J6xoLVftaDp1S3QibTn\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   394
        "3hv0KPuzsA7zi83GRp8STSHcwOU5zq5yzkFEPQrQxOYfaRzLrv7+sznXpaWCPb/6\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   395
        "wGktZrHBXZE0eT1wid7h3DoiOCu1BBLPAImiSk5SVadvQkk6uua4W3M78dzbrE8s\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   396
        "k6O40Nxyi3gVURU0U/IIm8ur89rYUThzlEdTKRdUfG38oyUvqFclwCbp+3F9BxIa\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   397
        "5WWmj0avrSFCAuwAoCY762Iah0bRv1SKTE9RzO1P07GNyyIuOZ2J6TlXVBWfzE9V\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   398
        "DmcCAwEAAaNTMFEwHQYDVR0OBBYEFBSupaksD+MluhuttqfbB/BNFEmXMB8GA1Ud\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   399
        "IwQYMBaAFBSupaksD+MluhuttqfbB/BNFEmXMA8GA1UdEwEB/wQFMAMBAf8wDQYJ\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   400
        "KoZIhvcNAQELBQADggEBALXVlY46/qvk7aVrDbJ/u/jmA+gGnEF7PZWg6tuwzME/\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   401
        "GDd28xwALHw+MgH6sFkKnCCfGnzuLPUMezMNLQxj+uosJvDHkBJ7hReDfowMcTz2\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   402
        "j0IR+RljNfGcd8lyfq9Jc6t8tTlPLG1ek/ObIMU/NLeK3faqGFLmoJ+xiDGVWhk3\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   403
        "uPhvc1l1riWaIP67PxpHOuBbOwwFyrkQ7jC0ymi0bdwG4m6BQ1KbWNXoWBnVSTNN\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   404
        "94C+FOEN6WnxwdX0BA2CPObs3YiUjctzXYaSixG952Lh6lwasrhqd1h6fogtTS4M\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   405
        "7dfJ99aNjmiQroC7xIe7OIRmGM/UbwA/K5zfQSayuNQ=\n" +
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   406
        "-----END CERTIFICATE-----",
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   407
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   408
        // SHA256withDSA, 2048 bits
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   409
        // Validity
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   410
        //     Not Before: Nov 25 04:19:56 2016 GMT
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   411
        //     Not After : Nov  5 04:19:56 2037 GMT
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   412
        // Subject Key Identifier:
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   413
        //     19:46:10:43:24:6A:A5:14:BE:E2:92:01:79:F0:4C:5F:E1:AE:81:B5
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   414
        "-----BEGIN CERTIFICATE-----\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   415
        "MIIFCzCCBLGgAwIBAgIJAOnEn6YZD/sAMAsGCWCGSAFlAwQDAjA7MQswCQYDVQQG\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   416
        "EwJVUzENMAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   417
        "Y2UwHhcNMTYxMTI1MDQxOTU2WhcNMzcxMTA1MDQxOTU2WjA7MQswCQYDVQQGEwJV\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   418
        "UzENMAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2Y2Uw\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   419
        "ggNGMIICOQYHKoZIzjgEATCCAiwCggEBAJa17ZYdIChv5yeYuPK3zXxgUEGGsdUD\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   420
        "AzfQUxtMryCtc3aNgWLxsN1/QYvp9v+hh4twnG20VemCEH9Qlx06Pxg74DwSOA83\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   421
        "SecO2y7cdgmrHpep9drxKbXVZafwBhbTSwhV+IDO7EO6+LaRvZuya/YOqNIE9ENx\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   422
        "FVk0NrNsDB6pfDEXZsCZALMN2mcl8KGn1q7vdzJQUEV7F6uLGP33znVfmQyWJH3Y\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   423
        "W09WVCFXHvDzZHGXDO2O2QwIU1B5AsXnOGeLnKgXzErCoNKwUbVFP0W0OVeJo4pc\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   424
        "ZfL/8TVELGG90AuuH1V3Gsq6PdzCDPw4Uv/v5m7/6kwXqBQxAJA7jhMCIQCORIGV\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   425
        "mHy5nBLRhIP4vC7vsTxb4CTApPVmZeL5gTIwtQKCAQB2VZLY22k2+IQM6deRGK3L\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   426
        "l7tPChGrKnGmTbtUThIza70Sp9DmTBiLzMEY+IgG8kYuT5STVxWjs0cxXCKZGMQW\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   427
        "tioMtiXPA2M3HA0/8E0mDLSmzb0RAd2xxnDyGsuqo1eVmx7PLjN3bn3EjhD/+j3d\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   428
        "Jx3ZVScMGyq7sVWppUvpudEXi+2etf6GUHjrcX27juo7u4zQ1ezC/HYG1H+jEFqG\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   429
        "hdQ6b7H+LBHZH9LegOyIZTMrzAY/TwIr77sXrNJWRoxmDErKB+8bRDybYhNJswlZ\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   430
        "m0N5YYUlPmepgbl6XzwCv0y0d81h3bayqIPLXEUtRAl9GuM0hNAlA1Y+qSn9xLFY\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   431
        "A4IBBQACggEAZgWC0uflwqQQP1GRU1tolmFZwyVtKre7SjYgCeQBrOa0Xnj/SLaD\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   432
        "g1HZ1oH0hccaR/45YouJiCretbbsQ77KouldGSGqTHJgRL75Y2z5uvxa60+YxZ0Z\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   433
        "v8xvZnj4seyOjgJLxSSYSPl5n/F70RaNiCLVz/kGe6OQ8KoAeQjdDTOHXCegO9KX\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   434
        "tvhM7EaYc8CII9OIR7S7PXJW0hgLKynZcu/Unh02aM0ABh/uLmw1+tvo8e8KTp98\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   435
        "NKYSVf6kV3/ya58n4h64UbIYL08JoKUM/5SFETcKAZTU0YKZbpWTM79oJMr8oYVk\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   436
        "P9jKitNsXq0Xkzt5dSO0kfu/kM7zpnaFsqOBrTCBqjAdBgNVHQ4EFgQUGUYQQyRq\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   437
        "pRS+4pIBefBMX+GugbUwawYDVR0jBGQwYoAUGUYQQyRqpRS+4pIBefBMX+GugbWh\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   438
        "P6Q9MDsxCzAJBgNVBAYTAlVTMQ0wCwYDVQQKEwRKYXZhMR0wGwYDVQQLExRTdW5K\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   439
        "U1NFIFRlc3QgU2VyaXZjZYIJAOnEn6YZD/sAMA8GA1UdEwEB/wQFMAMBAf8wCwYD\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   440
        "VR0PBAQDAgEGMAsGCWCGSAFlAwQDAgNHADBEAiAwBafz5RRR9nc4cCYoYuBlT/D9\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   441
        "9eayhkjhBY/zYunypwIgNp/JnFR88/T4hh36QfSKBGXId9RBCM6uaOkOKnEGkps=\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   442
        "-----END CERTIFICATE-----"
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   443
        };
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   444
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   445
    // End entity certificate.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   446
    private final static String[] endEntityCertStrs = {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   447
        // SHA256withECDSA, curve prime256v1
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   448
        // Validity
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   449
        //     Not Before: Nov 25 04:19:51 2016 GMT
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   450
        //     Not After : Aug 12 04:19:51 2036 GMT
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   451
        // Authority Key Identifier:
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   452
        //     CA:48:E8:00:C1:42:BD:59:9B:79:D9:B4:B4:CE:3F:68:0C:C8:C4:0C
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   453
        "-----BEGIN CERTIFICATE-----\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   454
        "MIIB1zCCAXygAwIBAgIJAPFq2QL/nUNZMAoGCCqGSM49BAMCMDsxCzAJBgNVBAYT\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   455
        "AlVTMQ0wCwYDVQQKEwRKYXZhMR0wGwYDVQQLExRTdW5KU1NFIFRlc3QgU2VyaXZj\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   456
        "ZTAeFw0xNjExMjUwNDE5NTFaFw0zNjA4MTIwNDE5NTFaMFUxCzAJBgNVBAYTAlVT\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   457
        "MQ0wCwYDVQQKDARKYXZhMR0wGwYDVQQLDBRTdW5KU1NFIFRlc3QgU2VyaXZjZTEY\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   458
        "MBYGA1UEAwwPUmVncmVzc2lvbiBUZXN0MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcD\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   459
        "QgAE4yvRGVvy9iVATyuHPJVdX6+lh/GLm/sRJ5qLT/3PVFOoNIvlEVNiARo7xhyj\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   460
        "2p6bnf32gNg5Ye+QCw20VUv9E6NPME0wCwYDVR0PBAQDAgPoMB0GA1UdDgQWBBSO\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   461
        "hHlHZQp9hyBfSGTSQWeszqMXejAfBgNVHSMEGDAWgBTKSOgAwUK9WZt52bS0zj9o\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   462
        "DMjEDDAKBggqhkjOPQQDAgNJADBGAiEAu3t6cvFglBAZfkhZlEwB04ZjUFqyfiRj\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   463
        "4Hr275E4ZoQCIQDUEonJHlmA19J6oobfR5lYsmoqPm1r0DPm/IiNNKGKKA==\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   464
        "-----END CERTIFICATE-----",
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   465
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   466
        // SHA256withRSA, 2048 bits
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   467
        // Validity
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   468
        //     Not Before: Apr 12 06:52:29 2018 GMT
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   469
        //     Not After : Apr  7 06:52:29 2038 GMT
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   470
        // Authority Key Identifier:
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   471
        //     14:AE:A5:A9:2C:0F:E3:25:BA:1B:AD:B6:A7:DB:07:F0:4D:14:49:97
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   472
        "-----BEGIN CERTIFICATE-----\n" +
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   473
        "MIIDDDCCAfQCCQDd9PfUCpKn0DANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJV\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   474
        "UzENMAsGA1UECgwESmF2YTEdMBsGA1UECwwUU3VuSlNTRSBUZXN0IFNlcml2Y2Uw\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   475
        "HhcNMTgwNDEyMDY1MjI5WhcNMzgwNDA3MDY1MjI5WjBVMQswCQYDVQQGEwJVUzEN\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   476
        "MAsGA1UECgwESmF2YTEdMBsGA1UECwwUU3VuSlNTRSBUZXN0IFNlcml2Y2UxGDAW\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   477
        "BgNVBAMMD1JlZ3Jlc3Npb24gVGVzdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   478
        "AQoCggEBAJWFd+AEAZWRBbua9ax4CJgyXoU3Nx9zwkxbxz2DGZ5sJb/64b/mKBz4\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   479
        "mgT6cknJPrCv3vLg9v6WzlpIqISzEP6ARxmMDTomt8ppRFqDq31uGJ3cKWvhpwG1\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   480
        "92HwJUxvbjZYvqszXA5piOtFWa+uBavKSF/dXXrMXijDl6LbL3GU4pZLmeUP8PRy\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   481
        "UfwWhcy3HikBIx7fGCcNB+dHXtB5DTgxdR8ypTCB5xFfhgL9EqO8X0pin+bubfpF\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   482
        "5IY68p5B4ob7EdNmBCTUyFAN3Mh9r49ZzwpYIvi9shNmddwMakJOB9YaMsRmc3Ea\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   483
        "mUVpdR0fR8bY5RtgZwEhtaizp2DkS0ECAwEAATANBgkqhkiG9w0BAQsFAAOCAQEA\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   484
        "pUqCPnpeUITq9tfDdB9rolb5dV3fIhRtj0rsjimKbcMAeYAkb3qHvlZOLZ/PMD3v\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   485
        "y8J9TJ88YPGGOUXCsAqJ88Ous883xqLkOjZYEiY/0gdU2/v6uQ35lgHtJynmzO3E\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   486
        "YUbwleJETUNA66sOtiW7om9vcAVPu3mmea5bZkkdwxydn/IZvVYp5JLu4MuJpfh1\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   487
        "lWpC3z2U7DgZrt4ZQGzok+DRnGiKIOo+G2JvLVIKz/rbsIbjDBqQTdt7TKLu8wbV\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   488
        "UdN8SOF7qZhBpiwQHZCmiw8KhQ5R/aNDQxCVfMOXcAGqmiFpdHPqWgxCob778mjc\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   489
        "Na2CGaztVh+f9MSz3j/Hmg==\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   490
        "-----END CERTIFICATE-----",
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   491
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   492
        // SHA256withRSA, curv prime256v1
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   493
        // Validity
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   494
        //     Not Before: Apr 12 06:54:43 2018 GMT
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   495
        //     Not After : Apr  7 06:54:43 2038 GMT
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   496
        // Authority Key Identifier:
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   497
        //     14:AE:A5:A9:2C:0F:E3:25:BA:1B:AD:B6:A7:DB:07:F0:4D:14:49:97
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   498
        "-----BEGIN CERTIFICATE-----\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   499
        "MIICQTCCASkCCQDd9PfUCpKn0TANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJV\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   500
        "UzENMAsGA1UECgwESmF2YTEdMBsGA1UECwwUU3VuSlNTRSBUZXN0IFNlcml2Y2Uw\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   501
        "HhcNMTgwNDEyMDY1NDQzWhcNMzgwNDA3MDY1NDQzWjBVMQswCQYDVQQGEwJVUzEN\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   502
        "MAsGA1UECgwESmF2YTEdMBsGA1UECwwUU3VuSlNTRSBUZXN0IFNlcml2Y2UxGDAW\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   503
        "BgNVBAMMD1JlZ3Jlc3Npb24gVGVzdDBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IA\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   504
        "BOlOthBVzSCU0TPRiW+O4mhOn0ZHE338wLhy4HYiMnuBVWzl2L7krSpCXKM/b//a\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   505
        "/0YPobAEXKbShh0oFxo51IIwDQYJKoZIhvcNAQELBQADggEBAD/a7z31ODFCSdyf\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   506
        "AUq5vYsVZIV4s2J2tJh5piYoipP0BKRcthw1RtvqbNZFjB5DLyWVq39Tk6gCJvKo\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   507
        "csaV3O/VRaQWRyLD1Ak7T0oG5eZDlpYWwjzyMMR32NjOyRG6clWWQx5O7Pc2uxvz\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   508
        "GL8Pf+YgKU5QLqcghN+104e3+GMzmNccmK5nBmr2Lz1Hy54JxGRXUEKI85VoiUgk\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   509
        "ArF0RLeUQxBFFBrYBsqLY6DI+Rgvhxk9ri9Udoa3sn8pYfNqxe1beyazbn4ChM6z\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   510
        "y/7/we+wAnPaPSReugkDO4w/XqUGKa26EiPrQ/9s0QGhKyqeNg/CRY+FEH0sEjuK\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   511
        "ycLgJK0=\n" +
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   512
        "-----END CERTIFICATE-----",
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   513
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   514
        // SHA256withDSA, 2048 bits
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   515
        // Validity
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   516
        //    Not Before: Nov 25 04:19:56 2016 GMT
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   517
        //    Not After : Aug 12 04:19:56 2036 GMT
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   518
        // Authority Key Identifier:
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   519
        //     19:46:10:43:24:6A:A5:14:BE:E2:92:01:79:F0:4C:5F:E1:AE:81:B5
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   520
        "-----BEGIN CERTIFICATE-----\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   521
        "MIIE2jCCBICgAwIBAgIJAONcI1oba9V9MAsGCWCGSAFlAwQDAjA7MQswCQYDVQQG\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   522
        "EwJVUzENMAsGA1UEChMESmF2YTEdMBsGA1UECxMUU3VuSlNTRSBUZXN0IFNlcml2\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   523
        "Y2UwHhcNMTYxMTI1MDQxOTU2WhcNMzYwODEyMDQxOTU2WjBVMQswCQYDVQQGEwJV\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   524
        "UzENMAsGA1UECgwESmF2YTEdMBsGA1UECwwUU3VuSlNTRSBUZXN0IFNlcml2Y2Ux\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   525
        "GDAWBgNVBAMMD1JlZ3Jlc3Npb24gVGVzdDCCA0YwggI5BgcqhkjOOAQBMIICLAKC\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   526
        "AQEAlrXtlh0gKG/nJ5i48rfNfGBQQYax1QMDN9BTG0yvIK1zdo2BYvGw3X9Bi+n2\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   527
        "/6GHi3CcbbRV6YIQf1CXHTo/GDvgPBI4DzdJ5w7bLtx2Casel6n12vEptdVlp/AG\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   528
        "FtNLCFX4gM7sQ7r4tpG9m7Jr9g6o0gT0Q3EVWTQ2s2wMHql8MRdmwJkAsw3aZyXw\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   529
        "oafWru93MlBQRXsXq4sY/ffOdV+ZDJYkfdhbT1ZUIVce8PNkcZcM7Y7ZDAhTUHkC\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   530
        "xec4Z4ucqBfMSsKg0rBRtUU/RbQ5V4mjilxl8v/xNUQsYb3QC64fVXcayro93MIM\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   531
        "/DhS/+/mbv/qTBeoFDEAkDuOEwIhAI5EgZWYfLmcEtGEg/i8Lu+xPFvgJMCk9WZl\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   532
        "4vmBMjC1AoIBAHZVktjbaTb4hAzp15EYrcuXu08KEasqcaZNu1ROEjNrvRKn0OZM\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   533
        "GIvMwRj4iAbyRi5PlJNXFaOzRzFcIpkYxBa2Kgy2Jc8DYzccDT/wTSYMtKbNvREB\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   534
        "3bHGcPIay6qjV5WbHs8uM3dufcSOEP/6Pd0nHdlVJwwbKruxVamlS+m50ReL7Z61\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   535
        "/oZQeOtxfbuO6ju7jNDV7ML8dgbUf6MQWoaF1Dpvsf4sEdkf0t6A7IhlMyvMBj9P\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   536
        "Aivvuxes0lZGjGYMSsoH7xtEPJtiE0mzCVmbQ3lhhSU+Z6mBuXpfPAK/TLR3zWHd\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   537
        "trKog8tcRS1ECX0a4zSE0CUDVj6pKf3EsVgDggEFAAKCAQBEGmdP55PyE3M+Q3fU\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   538
        "dCGq0sbKw/04xPVhaNYRnRKNR82n+wb8bMCI1vvFqXy1BB6svti4mTHbQZ8+bQXm\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   539
        "gyce67uYMwIa5BIk6omNGCeW/kd4ruPgyFxeb6O/Y/7w6AWyRmQttlxRA5M5OhSC\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   540
        "tVS4oVC1KK1EfHAUh7mu8S8GrWJoJAWA3PM97Oy/HSGCEUl6HGEu1m7FHPhOKeYG\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   541
        "cLkSaov5cbCYO76smHchI+tdUciVqeL3YKQdS+KAzsQoeAZIu/WpbaI1V+5/rSG1\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   542
        "I94uBITLCjlJfJZ1aredCDrRXOFH7qgSBhM8/WzwFpFCnnpbSKMgrcrKubsFmW9E\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   543
        "jQhXo2MwYTALBgNVHQ8EBAMCA+gwHQYDVR0OBBYEFNA9PhQOjB+05fxxXPNqe0OT\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   544
        "doCjMB8GA1UdIwQYMBaAFBlGEEMkaqUUvuKSAXnwTF/hroG1MBIGA1UdEQEB/wQI\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   545
        "MAaHBH8AAAEwCwYJYIZIAWUDBAMCA0cAMEQCIE0LM2sZi+L8tjH9sgjLEwJmYZvO\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   546
        "yqNfQnXrkTCb+MLMAiBZLaRTVJrOW3edQjum+SonKKuiN22bRclO6pGuNRCtng==\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   547
        "-----END CERTIFICATE-----"
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   548
        };
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   549
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   550
    // Private key in the format of PKCS#8.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   551
    private final static String[] endEntityPrivateKeys = {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   552
        //
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   553
        // EC private key related to cert endEntityCertStrs[0].
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   554
        //
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   555
        "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgGAy4Pxrd2keM7AdP\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   556
        "VNUMEO5iO681v4/tstVGfdXkCTuhRANCAATjK9EZW/L2JUBPK4c8lV1fr6WH8Yub\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   557
        "+xEnmotP/c9UU6g0i+URU2IBGjvGHKPanpud/faA2Dlh75ALDbRVS/0T",
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   558
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   559
        //
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   560
        // RSA private key related to cert endEntityCertStrs[1].
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   561
        //
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   562
        "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCVhXfgBAGVkQW7\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   563
        "mvWseAiYMl6FNzcfc8JMW8c9gxmebCW/+uG/5igc+JoE+nJJyT6wr97y4Pb+ls5a\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   564
        "SKiEsxD+gEcZjA06JrfKaURag6t9bhid3Clr4acBtfdh8CVMb242WL6rM1wOaYjr\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   565
        "RVmvrgWrykhf3V16zF4ow5ei2y9xlOKWS5nlD/D0clH8FoXMtx4pASMe3xgnDQfn\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   566
        "R17QeQ04MXUfMqUwgecRX4YC/RKjvF9KYp/m7m36ReSGOvKeQeKG+xHTZgQk1MhQ\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   567
        "DdzIfa+PWc8KWCL4vbITZnXcDGpCTgfWGjLEZnNxGplFaXUdH0fG2OUbYGcBIbWo\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   568
        "s6dg5EtBAgMBAAECggEBAI5toQ8HQesTRf67UaKEhMtVz6veOOgBAOhz1IrHwzOh\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   569
        "mSQS+9AskbFnLm/nkc6voMP2A84gdad2SALAi6Y8XMfRsein/EGUeCabt7zxB/5n\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   570
        "TZOyENLvFIMQryHf++efjcC/MIEsX1hrNz3FxfUPM9+8xMxstYsv+dGi32MGn171\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   571
        "G1AKFOqs/n0X16Sh1kLtkHq1xaqZJUYQyrBasFtCPDwCFhhkwsxGQZ2Dcy3gFDxy\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   572
        "5O5IMSxFtaoiTLrnA/X4MxM3OyA57EG+KWtrokahTMmhPwysodlIS8kw3ROtCYBx\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   573
        "7FLclf49LDtiUtjLoyF+I8WCr44/zp7c13HlBijoNAECgYEAxdSLeCkWSuopZmjP\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   574
        "j0Cj00pME3W3gsy/1QQxRM+FfRQ6U1evNLp4JKakJUlZ+/xtsd1H9a6FAEzrgcbJ\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   575
        "xY8W++3IFUNLYop9c9/VXaaKLG2QyfoqBNAHROKyRxoKihDdPgNFwxcwI2tWJEnE\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   576
        "kBDZ+Kn4dAcxO3j/nVzD/Gvg5PECgYEAwXyGSo7Xzf0zwej1uVx5kSOKfn5dRUbr\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   577
        "2DDUleMFm7pnOIDriQ+pz6euROJNieoesX1Bo/PaML2095ljb19DI9U1OWMXFhTL\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   578
        "lKH/yOuDAdUTswp085ohPOCr48+QWLL6Awicd08L6tjg7Fm4j+VXaaNBbXuXOfjG\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   579
        "KeK+FOU9i1ECgYA4NNcbYLEQv87bZdPy426oTWen774fz4SBRRuqbTuD+gdIPpVs\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   580
        "6b3Qy/e/EEQcr++KpVAYoWjwWOpgiNYy5yCkmz5JrEDy0l4qWeIJJZQEY2zLtePS\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   581
        "Ujh+fdohEWkFKR1yzQM5FpF6vrhOvxa1x9PmLoSEkraOKyaU0xJr2UqgQQKBgGG1\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   582
        "yPuN912HKMQcKTtaf+nT0PTgS6nYjvG2dyTaaNKj58yZDllBF7hOLauLvSyQlr97\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   583
        "SdLKKr3Cj8kaJSTxLq7B1QcOC3KTPdvpk4qbpKUgPbqE5Vq/01ky/JsnDvY8LBWs\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   584
        "G5gEyzfmHnA9Pv8sCmDGmRv49f3IrAoq/2L+AX6BAoGBAJ1Wf2Qg8ox75ir0e1kH\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   585
        "8r+Lmr3gsoxKfh/0fTPV5mbH7PBOSzXwg5fiDUngy9aMDkqCAum5y2Jg0aHhx1Df\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   586
        "0dTiKsMBCEmPI3/2/O6gJ+HJ0xX6LxmwU9m21xM055IuS5oDXJhonJa2fWusQS1s\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   587
        "oqd5EGtoPFy0ccqHzYCv3F5A",
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   588
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   589
        //
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   590
        // EC private key related to cert endEntityCertStrs[2].
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   591
        //
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   592
        "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgomzbfLMRU6+4FNsa\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   593
        "KQ+qutNxLGgKmRcXWGbFKt71RzqhRANCAATpTrYQVc0glNEz0YlvjuJoTp9GRxN9\n" +
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   594
        "/MC4cuB2IjJ7gVVs5di+5K0qQlyjP2//2v9GD6GwBFym0oYdKBcaOdSC",
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   595
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   596
        //
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   597
        // DSA private key related to cert endEntityCertStrs[3].
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   598
        //
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   599
        "MIICZAIBADCCAjkGByqGSM44BAEwggIsAoIBAQCWte2WHSAob+cnmLjyt818YFBB\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   600
        "hrHVAwM30FMbTK8grXN2jYFi8bDdf0GL6fb/oYeLcJxttFXpghB/UJcdOj8YO+A8\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   601
        "EjgPN0nnDtsu3HYJqx6XqfXa8Sm11WWn8AYW00sIVfiAzuxDuvi2kb2bsmv2DqjS\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   602
        "BPRDcRVZNDazbAweqXwxF2bAmQCzDdpnJfChp9au73cyUFBFexerixj99851X5kM\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   603
        "liR92FtPVlQhVx7w82RxlwztjtkMCFNQeQLF5zhni5yoF8xKwqDSsFG1RT9FtDlX\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   604
        "iaOKXGXy//E1RCxhvdALrh9VdxrKuj3cwgz8OFL/7+Zu/+pMF6gUMQCQO44TAiEA\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   605
        "jkSBlZh8uZwS0YSD+Lwu77E8W+AkwKT1ZmXi+YEyMLUCggEAdlWS2NtpNviEDOnX\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   606
        "kRity5e7TwoRqypxpk27VE4SM2u9EqfQ5kwYi8zBGPiIBvJGLk+Uk1cVo7NHMVwi\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   607
        "mRjEFrYqDLYlzwNjNxwNP/BNJgy0ps29EQHdscZw8hrLqqNXlZsezy4zd259xI4Q\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   608
        "//o93Scd2VUnDBsqu7FVqaVL6bnRF4vtnrX+hlB463F9u47qO7uM0NXswvx2BtR/\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   609
        "oxBahoXUOm+x/iwR2R/S3oDsiGUzK8wGP08CK++7F6zSVkaMZgxKygfvG0Q8m2IT\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   610
        "SbMJWZtDeWGFJT5nqYG5el88Ar9MtHfNYd22sqiDy1xFLUQJfRrjNITQJQNWPqkp\n" +
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   611
        "/cSxWAQiAiAKHYbYwEy0XS9J0MeKQmqPswn0nCJKvH+esfMKkZvV3w=="
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   612
        };
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   613
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   614
    // Private key algorithm of endEntityPrivateKeys.
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   615
    private final static String[] endEntityPrivateKeyAlgs = {
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   616
        "EC",
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   617
        "RSA",
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   618
        "EC",
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   619
        "DSA",
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   620
        };
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   621
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   622
    // Private key names of endEntityPrivateKeys.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   623
    private final static String[] endEntityPrivateKeyNames = {
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   624
        "ecdsa",
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   625
        "rsa",
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   626
        "ec-rsa",
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   627
        "dsa",
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   628
        };
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   629
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   630
    /*
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   631
     * Create an instance of SSLContext with the specified trust/key materials.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   632
     */
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   633
    private SSLContext createSSLContext(
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   634
            String[] trustedMaterials,
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   635
            String[] keyMaterialCerts,
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   636
            String[] keyMaterialKeys,
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   637
            String[] keyMaterialKeyAlgs,
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   638
            String[] keyMaterialKeyNames,
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   639
            ContextParameters params) throws Exception {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   640
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   641
        KeyStore ts = null;     // trust store
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   642
        KeyStore ks = null;     // key store
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   643
        char passphrase[] = "passphrase".toCharArray();
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   644
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   645
        // Generate certificate from cert string.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   646
        CertificateFactory cf = CertificateFactory.getInstance("X.509");
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   647
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   648
        // Import the trused certs.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   649
        ByteArrayInputStream is;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   650
        if (trustedMaterials != null && trustedMaterials.length != 0) {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   651
            ts = KeyStore.getInstance("JKS");
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   652
            ts.load(null, null);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   653
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   654
            Certificate[] trustedCert =
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   655
                    new Certificate[trustedMaterials.length];
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   656
            for (int i = 0; i < trustedMaterials.length; i++) {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   657
                String trustedCertStr = trustedMaterials[i];
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   658
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   659
                is = new ByteArrayInputStream(trustedCertStr.getBytes());
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   660
                try {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   661
                    trustedCert[i] = cf.generateCertificate(is);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   662
                } finally {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   663
                    is.close();
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   664
                }
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   665
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   666
                ts.setCertificateEntry("trusted-cert-" + i, trustedCert[i]);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   667
            }
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   668
        }
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   669
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   670
        // Import the key materials.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   671
        //
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   672
        // Note that certification pathes bigger than one are not supported yet.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   673
        boolean hasKeyMaterials =
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   674
            (keyMaterialCerts != null) && (keyMaterialCerts.length != 0) &&
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   675
            (keyMaterialKeys != null) && (keyMaterialKeys.length != 0) &&
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   676
            (keyMaterialKeyAlgs != null) && (keyMaterialKeyAlgs.length != 0) &&
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   677
            (keyMaterialCerts.length == keyMaterialKeys.length) &&
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   678
            (keyMaterialCerts.length == keyMaterialKeyAlgs.length);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   679
        if (hasKeyMaterials) {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   680
            ks = KeyStore.getInstance("JKS");
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   681
            ks.load(null, null);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   682
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   683
            for (int i = 0; i < keyMaterialCerts.length; i++) {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   684
                String keyCertStr = keyMaterialCerts[i];
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   685
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   686
                // generate the private key.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   687
                PKCS8EncodedKeySpec priKeySpec = new PKCS8EncodedKeySpec(
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   688
                    Base64.getMimeDecoder().decode(keyMaterialKeys[i]));
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   689
                KeyFactory kf =
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   690
                    KeyFactory.getInstance(keyMaterialKeyAlgs[i]);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   691
                PrivateKey priKey = kf.generatePrivate(priKeySpec);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   692
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   693
                // generate certificate chain
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   694
                is = new ByteArrayInputStream(keyCertStr.getBytes());
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   695
                Certificate keyCert = null;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   696
                try {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   697
                    keyCert = cf.generateCertificate(is);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   698
                } finally {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   699
                    is.close();
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   700
                }
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   701
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   702
                Certificate[] chain = new Certificate[] { keyCert };
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   703
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   704
                // import the key entry.
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   705
                ks.setKeyEntry("cert-" + keyMaterialKeyNames[i],
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   706
                        priKey, passphrase, chain);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   707
            }
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   708
        }
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   709
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   710
        // Create an SSLContext object.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   711
        TrustManagerFactory tmf =
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   712
                TrustManagerFactory.getInstance(params.tmAlgorithm);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   713
        tmf.init(ts);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   714
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   715
        SSLContext context = SSLContext.getInstance(params.contextProtocol);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   716
        if (hasKeyMaterials && ks != null) {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   717
            KeyManagerFactory kmf =
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   718
                    KeyManagerFactory.getInstance(params.kmAlgorithm);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   719
            kmf.init(ks, passphrase);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   720
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   721
            context.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   722
        } else {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   723
            context.init(null, tmf.getTrustManagers(), null);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   724
        }
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   725
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   726
        return context;
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   727
    }
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   728
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   729
    /*
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   730
     * =================================================
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   731
     * Stuffs to boot up the client-server mode testing.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   732
     */
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   733
    private Thread clientThread = null;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   734
    private Thread serverThread = null;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   735
    private volatile Exception serverException = null;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   736
    private volatile Exception clientException = null;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   737
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   738
    /*
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   739
     * Should we run the client or server in a separate thread?
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   740
     * Both sides can throw exceptions, but do you have a preference
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   741
     * as to which side should be the main thread.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   742
     */
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   743
    private static final boolean separateServerThread = false;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   744
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   745
    /*
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   746
     * Boot up the testing, used to drive remainder of the test.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   747
     */
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   748
    private void bootup() throws Exception {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   749
        Exception startException = null;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   750
        try {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   751
            if (separateServerThread) {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   752
                startServer(true);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   753
                startClient(false);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   754
            } else {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   755
                startClient(true);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   756
                startServer(false);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   757
            }
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   758
        } catch (Exception e) {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   759
            startException = e;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   760
        }
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   761
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   762
        /*
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   763
         * Wait for other side to close down.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   764
         */
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   765
        if (separateServerThread) {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   766
            if (serverThread != null) {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   767
                serverThread.join();
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   768
            }
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   769
        } else {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   770
            if (clientThread != null) {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   771
                clientThread.join();
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   772
            }
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   773
        }
42155
c9b28ab5297b 8168969: Merge SSLSocketSample and SSLSocketTemplate
asmotrak
parents: 41595
diff changeset
   774
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   775
        /*
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   776
         * When we get here, the test is pretty much over.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   777
         * Which side threw the error?
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   778
         */
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   779
        Exception local;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   780
        Exception remote;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   781
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   782
        if (separateServerThread) {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   783
            remote = serverException;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   784
            local = clientException;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   785
        } else {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   786
            remote = clientException;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   787
            local = serverException;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   788
        }
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   789
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   790
        Exception exception = null;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   791
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   792
        /*
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   793
         * Check various exception conditions.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   794
         */
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   795
        if ((local != null) && (remote != null)) {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   796
            // If both failed, return the curthread's exception.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   797
            local.initCause(remote);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   798
            exception = local;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   799
        } else if (local != null) {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   800
            exception = local;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   801
        } else if (remote != null) {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   802
            exception = remote;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   803
        } else if (startException != null) {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   804
            exception = startException;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   805
        }
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   806
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   807
        /*
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   808
         * If there was an exception *AND* a startException,
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   809
         * output it.
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   810
         */
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   811
        if (exception != null) {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   812
            if (exception != startException && startException != null) {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   813
                exception.addSuppressed(startException);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   814
            }
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   815
            throw exception;
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   816
        }
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   817
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   818
        // Fall-through: no exception to throw!
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   819
    }
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   820
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   821
    private void startServer(boolean newThread) throws Exception {
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   822
        if (newThread) {
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   823
            serverThread = new Thread() {
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   824
                @Override
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   825
                public void run() {
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   826
                    try {
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   827
                        doServerSide();
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   828
                    } catch (Exception e) {
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   829
                        /*
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   830
                         * Our server thread just died.
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   831
                         *
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   832
                         * Release the client, if not active already...
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   833
                         */
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   834
                        logException("Server died", e);
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   835
                        serverException = e;
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   836
                    }
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   837
                }
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   838
            };
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   839
            serverThread.start();
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   840
        } else {
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   841
            try {
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   842
                doServerSide();
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   843
            } catch (Exception e) {
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   844
                logException("Server failed", e);
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   845
                serverException = e;
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   846
            }
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   847
        }
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   848
    }
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   849
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   850
    private void startClient(boolean newThread) throws Exception {
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   851
        if (newThread) {
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   852
            clientThread = new Thread() {
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   853
                @Override
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   854
                public void run() {
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   855
                    try {
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   856
                        doClientSide();
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   857
                    } catch (Exception e) {
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   858
                        /*
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   859
                         * Our client thread just died.
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   860
                         */
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   861
                        logException("Client died", e);
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   862
                        clientException = e;
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   863
                    }
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   864
                }
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   865
            };
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   866
            clientThread.start();
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   867
        } else {
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   868
            try {
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   869
                doClientSide();
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   870
            } catch (Exception e) {
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   871
                logException("Client failed", e);
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   872
                clientException = e;
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   873
            }
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   874
        }
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   875
    }
42464
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   876
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   877
    private synchronized void logException(String prefix, Throwable cause) {
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   878
        System.out.println(prefix + ": " + cause);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   879
        cause.printStackTrace(System.out);
38d967704a9f 8170329: New SSLSocket testing template
xuelei
parents: 42164
diff changeset
   880
    }
41196
240314163e51 8164591: sun/net/www/protocol/https/HttpsClient/ServerIdentityTest.java failed with SSLHandshakeException
asmotrak
parents:
diff changeset
   881
}
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   882