jdk/test/javax/net/ssl/TLS/CipherTestUtils.java
author ihse
Tue, 09 May 2017 12:57:30 +0200
changeset 45028 b0ea3c0bfb81
parent 39140 86f21a96d0ab
permissions -rw-r--r--
8179889: Fix typographic errors in copyright headers Reviewed-by: erikj, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
     1
/*
38430
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
     2
 * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
     4
 *
45028
b0ea3c0bfb81 8179889: Fix typographic errors in copyright headers
ihse
parents: 39140
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
b0ea3c0bfb81 8179889: Fix typographic errors in copyright headers
ihse
parents: 39140
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
b0ea3c0bfb81 8179889: Fix typographic errors in copyright headers
ihse
parents: 39140
diff changeset
     7
 * published by the Free Software Foundation.
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
     8
 *
45028
b0ea3c0bfb81 8179889: Fix typographic errors in copyright headers
ihse
parents: 39140
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
b0ea3c0bfb81 8179889: Fix typographic errors in copyright headers
ihse
parents: 39140
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b0ea3c0bfb81 8179889: Fix typographic errors in copyright headers
ihse
parents: 39140
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b0ea3c0bfb81 8179889: Fix typographic errors in copyright headers
ihse
parents: 39140
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
b0ea3c0bfb81 8179889: Fix typographic errors in copyright headers
ihse
parents: 39140
diff changeset
    13
 * accompanied this code).
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    14
 *
45028
b0ea3c0bfb81 8179889: Fix typographic errors in copyright headers
ihse
parents: 39140
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
b0ea3c0bfb81 8179889: Fix typographic errors in copyright headers
ihse
parents: 39140
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
b0ea3c0bfb81 8179889: Fix typographic errors in copyright headers
ihse
parents: 39140
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    18
 *
45028
b0ea3c0bfb81 8179889: Fix typographic errors in copyright headers
ihse
parents: 39140
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b0ea3c0bfb81 8179889: Fix typographic errors in copyright headers
ihse
parents: 39140
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    21
 * questions.
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    22
 */
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    23
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    24
import java.io.ByteArrayInputStream;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    25
import java.io.EOFException;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    26
import java.io.File;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    27
import java.io.FileInputStream;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    28
import java.io.FileNotFoundException;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    29
import java.io.IOException;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    30
import java.io.InputStream;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    31
import java.io.OutputStream;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    32
import java.net.Socket;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    33
import java.security.KeyFactory;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    34
import java.security.KeyStore;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    35
import java.security.KeyStoreException;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    36
import java.security.NoSuchAlgorithmException;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    37
import java.security.Principal;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    38
import java.security.PrivateKey;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    39
import java.security.SecureRandom;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    40
import java.security.UnrecoverableKeyException;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    41
import java.security.cert.Certificate;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    42
import java.security.cert.CertificateException;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    43
import java.security.cert.CertificateFactory;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    44
import java.security.cert.X509Certificate;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    45
import java.security.interfaces.RSAPrivateKey;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    46
import java.security.spec.InvalidKeySpecException;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    47
import java.security.spec.PKCS8EncodedKeySpec;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    48
import java.util.ArrayList;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    49
import java.util.Arrays;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    50
import java.util.Base64;
31419
da88ed1523b8 8069253: javax/net/ssl/TLS/TestJSSE.java failed on Mac
weijun
parents: 30904
diff changeset
    51
import java.util.Collections;
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    52
import java.util.List;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    53
import javax.net.ssl.KeyManagerFactory;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    54
import javax.net.ssl.SSLEngine;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    55
import javax.net.ssl.SSLServerSocket;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    56
import javax.net.ssl.SSLSocket;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    57
import javax.net.ssl.SSLSocketFactory;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    58
import javax.net.ssl.TrustManager;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    59
import javax.net.ssl.TrustManagerFactory;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    60
import javax.net.ssl.X509ExtendedKeyManager;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    61
import javax.net.ssl.X509TrustManager;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    62
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    63
/**
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    64
 * Test that all ciphersuites work in all versions and all client authentication
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    65
 * types. The way this is setup the server is stateless and all checking is done
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    66
 * on the client side.
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    67
 */
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    68
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    69
public class CipherTestUtils {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    70
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    71
    public static final int TIMEOUT = 20 * 1000;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    72
    public static final SecureRandom secureRandom = new SecureRandom();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    73
    public static char[] PASSWORD = "passphrase".toCharArray();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    74
    private static final List<TestParameters> TESTS = new ArrayList<>(3);
31419
da88ed1523b8 8069253: javax/net/ssl/TLS/TestJSSE.java failed on Mac
weijun
parents: 30904
diff changeset
    75
    private static final List<Exception> EXCEPTIONS
da88ed1523b8 8069253: javax/net/ssl/TLS/TestJSSE.java failed on Mac
weijun
parents: 30904
diff changeset
    76
            = Collections.synchronizedList(new ArrayList<>(1));
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
    77
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    78
    private static final String CLIENT_PUBLIC_KEY
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    79
        = "-----BEGIN CERTIFICATE-----\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    80
        + "MIICtTCCAh4CCQDkYJ46DMcGRjANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMC\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    81
        + "VVMxCzAJBgNVBAgMAkNBMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3MR8wHQYDVQQK\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    82
        + "DBZTdW4gTWljcm9zeXN0ZW1zLCBJbmMuMSYwJAYDVQQLDB1TdW4gTWljcm9zeXN0\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    83
        + "ZW1zIExhYm9yYXRvcmllczEfMB0GA1UEAwwWVGVzdCBDQSAoMTAyNCBiaXQgUlNB\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    84
        + "KTAeFw0wOTA0MjcwNDA0MDhaFw0xMzA2MDUwNDA0MDhaMIGgMQswCQYDVQQGEwJV\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    85
        + "UzELMAkGA1UECAwCQ0ExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxHzAdBgNVBAoM\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    86
        + "FlN1biBNaWNyb3N5c3RlbXMsIEluYy4xJjAkBgNVBAsMHVN1biBNaWNyb3N5c3Rl\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    87
        + "bXMgTGFib3JhdG9yaWVzMSMwIQYDVQQDDBpUZXN0IENsaWVudCAoMTAyNCBiaXQg\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    88
        + "UlNBKTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAm5rwjmhO7Nwd5GWs+KvQ\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    89
        + "UnDiqpRDvRriOUFdF0rCI2Op24C+iwUMDGxPsgP7VkUpOdJhw3c72aP0CAWcZ5dN\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    90
        + "UCW7WVDAxnogCahLCir1jjoGdEjiNGOy0L9sypsM9UvBzJN8uvXsxsTZX4Z88cKU\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    91
        + "G7RUvN8LQ88zDljk5zr3c2MCAwEAATANBgkqhkiG9w0BAQUFAAOBgQA7LUDrzHln\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    92
        + "EXuGmwZeeroACB6DVtkClMskF/Pj5GnTxoeNN9DggycX/eOeIDKRloHuMpBeZPJH\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    93
        + "NUwFu4LB6HBDeldQD9iRp8zD/fPakOdN+1Gk5hciIZZJ5hQmeCl7Va2Gr64vUqZG\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    94
        + "MkVU755t+7ByLgzWuhPhhsX9QCuPR5FjvQ==\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    95
        + "-----END CERTIFICATE-----";
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    96
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    97
    private static final String CLIENT_PRIVATE_KEY
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    98
        = "-----BEGIN PRIVATE KEY-----\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
    99
        + "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJua8I5oTuzcHeRl\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   100
        + "rPir0FJw4qqUQ70a4jlBXRdKwiNjqduAvosFDAxsT7ID+1ZFKTnSYcN3O9mj9AgF\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   101
        + "nGeXTVAlu1lQwMZ6IAmoSwoq9Y46BnRI4jRjstC/bMqbDPVLwcyTfLr17MbE2V+G\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   102
        + "fPHClBu0VLzfC0PPMw5Y5Oc693NjAgMBAAECgYA5w73zj8Nk6J3sMNaShe3S/PcY\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   103
        + "TewLopRCnwI46FbDnnbq9pNFtnzvi7HWKuY983THc1M5peTA+b1Y0QRr7F4Vg4x9\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   104
        + "9UM0B/tZcIIcJJ3LS+9fXKCbYLQWq5F05JqeZu+i+QLmJFO5+2p7laeQ4oQfW7QE\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   105
        + "YR4u2mSaLe0SsqHvOQJBAMhgcye9C6pJO0eo2/VtRxAXI7zxNAIjHwKo1cva7bhu\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   106
        + "GdrMaEAJBAsMJ1GEk7/WDI+3KEbTjQdfIJuAvOR4FXUCQQDGzNn/tl2k93v/ugyM\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   107
        + "/tBhCKDipYDIbyJMoG2AOtOGmCsiGo5L7idO4OAcm/QiHBQMXjFIVgTUcH8MhGj4\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   108
        + "blJ3AkA5fUqsxRV6tuYWKkFpif/QgwMS65VDY7Y6+hvVECwSNSyf1PO4I54QWV1S\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   109
        + "ixok+RHDjgY1Q+77hXSCiQ4o8rcdAkBHvjfR+5sx5IpgUGElJPRIgFenU3j1XH3x\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   110
        + "T1gVFaWuhg3S4eiGaGzRH4BhcrqY8K8fg4Kfi0N08yA2gTZsqUujAkEAjuNPTuKx\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   111
        + "ti0LXI09kbGUqOpRMm1zW5TD6LFeEaUN6oxrSZI2YUvu7VyotAqsxX5O0u0f3VQw\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   112
        + "ySF0Q1oZ6qu7cg==\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   113
        + "-----END PRIVATE KEY-----";
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   114
    private static final String SERVER_PUBLIC_KEY
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   115
        = "-----BEGIN CERTIFICATE-----\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   116
        + "MIICtTCCAh4CCQDkYJ46DMcGRTANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMC\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   117
        + "VVMxCzAJBgNVBAgMAkNBMRYwFAYDVQQHDA1Nb3VudGFpbiBWaWV3MR8wHQYDVQQK\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   118
        + "DBZTdW4gTWljcm9zeXN0ZW1zLCBJbmMuMSYwJAYDVQQLDB1TdW4gTWljcm9zeXN0\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   119
        + "ZW1zIExhYm9yYXRvcmllczEfMB0GA1UEAwwWVGVzdCBDQSAoMTAyNCBiaXQgUlNB\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   120
        + "KTAeFw0wOTA0MjcwNDA0MDhaFw0xMzA2MDUwNDA0MDhaMIGgMQswCQYDVQQGEwJV\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   121
        + "UzELMAkGA1UECAwCQ0ExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxHzAdBgNVBAoM\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   122
        + "FlN1biBNaWNyb3N5c3RlbXMsIEluYy4xJjAkBgNVBAsMHVN1biBNaWNyb3N5c3Rl\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   123
        + "bXMgTGFib3JhdG9yaWVzMSMwIQYDVQQDDBpUZXN0IFNlcnZlciAoMTAyNCBiaXQg\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   124
        + "UlNBKTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEArsHHeZ1O67yuxQKDSAOC\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   125
        + "Xm271ViwBrXkxe5cvhG8MCCem6Z3XeZ/m6c2ucRwLaQxnmG1m0G6/OYaUXTivjcG\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   126
        + "/K4bc1I+yjghAWQNLBtsOiP9w0LKibg3TSDehpeuuz/lmB5A4HMqQr8KkY4K7peD\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   127
        + "1QkJ2Dn3zhbwQ/0d8f5CCbkCAwEAATANBgkqhkiG9w0BAQUFAAOBgQBOd8XojEnu\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   128
        + "eTUHBwqfmnvRQvbICFDNbbL4KuX/JNPSy1WMGAEbNCTLZ+5yP69js8aUYqAk5vVf\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   129
        + "dWRLU3MDiEzW7zxE1ubuKWjVuyGbG8Me0G01Hw+evBcZqB64Fz3OFISVfQh7MqE/\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   130
        + "O0AeakRMH350FRLNl4o6KBSXmF/AADfqQQ==\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   131
        + "-----END CERTIFICATE-----";
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   132
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   133
    private static final String SERVER_PRIVATE_KEY
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   134
        = "-----BEGIN PRIVATE KEY-----\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   135
        + "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAK7Bx3mdTuu8rsUC\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   136
        + "g0gDgl5tu9VYsAa15MXuXL4RvDAgnpumd13mf5unNrnEcC2kMZ5htZtBuvzmGlF0\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   137
        + "4r43BvyuG3NSPso4IQFkDSwbbDoj/cNCyom4N00g3oaXrrs/5ZgeQOBzKkK/CpGO\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   138
        + "Cu6Xg9UJCdg5984W8EP9HfH+Qgm5AgMBAAECgYAXUv+3qJo+9mjxHHu/IdDFn6nB\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   139
        + "ONwNmTtWe5DfQWi3l7LznU0zOC9x6+hu9NvwC4kf1XSyqxw04tVCZ/JXZurEmEBz\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   140
        + "YtcQ5idRQDkKYXEDOeVUfvtHO6xilzrhPKxxd0GG/sei2pozikkqnYF3OcP0qL+a\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   141
        + "3nWixZQBRoF2nIRLcQJBAN97TJBr0XTRmE7OCKLUy1+ws7vZB9uQ2efHMsgwOpsY\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   142
        + "3cEW5qd95hrxLU72sBeu9loHQgBrT2Q3OAxnsPXmgO0CQQDIL3u9kS/O3Ukx+n1H\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   143
        + "JdPFQCRxrDm/vtJpQEmq+mLqxxnxCFRIYQ2ieAPokBxWeMDtdWJGD3VxhahjPfZm\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   144
        + "5K59AkEAuDVl0tVMfUIWjT5/F9jXGjUIsZofQ/iN5OLpFOHMLPO+Nd6umPjJpwON\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   145
        + "GT11wM/S+DprSPUrJ6vsYy1FTCuHsQJBAMXtnO07xgdE6AAQaRmVnyMiXmY+IQMj\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   146
        + "CyuhsrToyDDWFyIoWB0QSMjg3QxuoHYnAqpGK5qV4ksSGgG13BCz/okCQQCRHTgn\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   147
        + "DuFG2f7GYLFjI4NaTEzHGp+J9LiNYY1kYYLonpwAC3Z5hzJVanYT3/g23AUZ/fdF\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   148
        + "v5PDIViuPo5ZB1eD\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   149
        + "-----END PRIVATE KEY-----";
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   150
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   151
    private static final String CA_PUBLIC_KEY
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   152
        = "-----BEGIN CERTIFICATE-----\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   153
        + "MIIDCDCCAnGgAwIBAgIJAIYlGfwNBY6NMA0GCSqGSIb3DQEBBQUAMIGcMQswCQYD\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   154
        + "VQQGEwJVUzELMAkGA1UECAwCQ0ExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxHzAd\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   155
        + "BgNVBAoMFlN1biBNaWNyb3N5c3RlbXMsIEluYy4xJjAkBgNVBAsMHVN1biBNaWNy\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   156
        + "b3N5c3RlbXMgTGFib3JhdG9yaWVzMR8wHQYDVQQDDBZUZXN0IENBICgxMDI0IGJp\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   157
        + "dCBSU0EpMB4XDTA5MDQyNzA0MDQwOFoXDTEzMDYwNTA0MDQwOFowgZwxCzAJBgNV\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   158
        + "BAYTAlVTMQswCQYDVQQIDAJDQTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEfMB0G\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   159
        + "A1UECgwWU3VuIE1pY3Jvc3lzdGVtcywgSW5jLjEmMCQGA1UECwwdU3VuIE1pY3Jv\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   160
        + "c3lzdGVtcyBMYWJvcmF0b3JpZXMxHzAdBgNVBAMMFlRlc3QgQ0EgKDEwMjQgYml0\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   161
        + "IFJTQSkwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOK4DJxxb0XX6MJ1CVjp\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   162
        + "9Gmr/Ua8MS12R58F9lDpSKuq8cFexA4W7OdZ4jtbKv0tRHX5YxmbnXedwS+gdcOA\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   163
        + "GRgXMoeXlgTFGpdL+TR8xKIlMGRSjnR7MpR2tRyIYI2p+UTEiD6LTlIm5Wh4z1q8\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   164
        + "LYbxyMVD1XNNNymvPM44OjsBAgMBAAGjUDBOMB0GA1UdDgQWBBT27BLUflmfdtbi\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   165
        + "WTgjwWnoxop2MTAfBgNVHSMEGDAWgBT27BLUflmfdtbiWTgjwWnoxop2MTAMBgNV\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   166
        + "HRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAEQELNzhZpjnSgigd+QJ6I/3CPDo\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   167
        + "SDkMLdP1BHlT/DkMIZvABm+M09ePNlWiLYCNCsL9nWmX0gw0rFDKsTklZyKTUzaM\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   168
        + "oy/AZCrAaoIc6SO5m1xE1RMyVxd/Y/kg6cbfWxxCJFlMeU5rsSdC97HTE/lDyuoh\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   169
        + "BmlOBB7SdR+1ScjA\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   170
        + "-----END CERTIFICATE-----";
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   171
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   172
    private static final String CA_PRIVATE_KEY
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   173
        = "-----BEGIN PRIVATE KEY-----\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   174
        + "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAOK4DJxxb0XX6MJ1\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   175
        + "CVjp9Gmr/Ua8MS12R58F9lDpSKuq8cFexA4W7OdZ4jtbKv0tRHX5YxmbnXedwS+g\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   176
        + "dcOAGRgXMoeXlgTFGpdL+TR8xKIlMGRSjnR7MpR2tRyIYI2p+UTEiD6LTlIm5Wh4\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   177
        + "z1q8LYbxyMVD1XNNNymvPM44OjsBAgMBAAECgYEApmMOlk3FrQtsvjGof4GLp3Xa\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   178
        + "tmvs54FzxKhagj0C4UHelNyYpAJ9MLjNiGQ7I31yTeaNrUCAi0XSfsKTSrwbLSnJ\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   179
        + "qsUPKMBrnzcWrOyui2+cupHZXaTlNeYB97teLJYpa6Ql9CZLoTHoim1+//s7diBh\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   180
        + "03Vls+M6Poi5PMvv59UCQQD+k/BiokmbBgWHfBY5cZSlx3Z4VTwSHJmHDTO3Tjso\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   181
        + "EVErXUSVvqD/KHX6eM4VPM8lySV5djWV8lDsESCWMtiLAkEA4/xFNsiOLMQpxW/O\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   182
        + "bt2tukxJkAxldD4lPoFZR+zbXtMtt8OjERtX2wD+nj6h7jfIeSyVuBEcBN8Uj8xe\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   183
        + "kgfgIwJAPbKG4LCqHAsCjgpRrIxNVTwZByLJEy6hOqzFathn19cSj+rjs1Lm28/n\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   184
        + "f9OFRnpdTbAJB/3REM0QNZYVCrG57wJBAN0KuTytZJNouaswhPCew5Kt5mDgc/kp\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   185
        + "S8j3dk2zCto8W8Ygy1iJrzuqEjPxO+UQdrFtlde51vWuKGxnVIW3VwsCQEldqk7r\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   186
        + "8y7PgquPP+k3L0OXno5wGBrPcW1+U0mhIZGnwSzE4SPX2ddqUSEUA/Av4RjAckL/\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   187
        + "fpqmCkpTanyYW9U=\n"
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   188
        + "-----END PRIVATE KEY-----";
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   189
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   190
    private final SSLSocketFactory factory;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   191
    private final X509ExtendedKeyManager clientKeyManager;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   192
    private final X509ExtendedKeyManager serverKeyManager;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   193
    private final X509TrustManager clientTrustManager;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   194
    private final X509TrustManager serverTrustManager;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   195
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   196
    static abstract class Server implements Runnable, AutoCloseable {
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   197
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   198
        final CipherTestUtils cipherTest;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   199
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   200
        Server(CipherTestUtils cipherTest) throws Exception {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   201
            this.cipherTest = cipherTest;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   202
        }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   203
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   204
        @Override
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   205
        public abstract void run();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   206
38430
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   207
        abstract int getPort();
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   208
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   209
        void handleRequest(InputStream in, OutputStream out)
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   210
                throws IOException {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   211
            boolean newline = false;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   212
            StringBuilder sb = new StringBuilder();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   213
            while (true) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   214
                int ch = in.read();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   215
                if (ch < 0) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   216
                    throw new EOFException();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   217
                }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   218
                sb.append((char) ch);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   219
                if (ch == '\r') {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   220
                    // empty
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   221
                } else if (ch == '\n') {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   222
                    if (newline) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   223
                        // 2nd newline in a row, end of request
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   224
                        break;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   225
                    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   226
                    newline = true;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   227
                } else {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   228
                    newline = false;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   229
                }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   230
            }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   231
            String request = sb.toString();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   232
            if (request.startsWith("GET / HTTP/1.") == false) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   233
                throw new IOException("Invalid request: " + request);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   234
            }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   235
            out.write("HTTP/1.0 200 OK\r\n\r\n".getBytes());
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   236
            out.write("Tested Scenario: ".getBytes());
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   237
            TestParameters tp = (TestParameters) CipherTestUtils.TESTS.get(0);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   238
            out.write(tp.toString().getBytes());
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   239
            out.write(" Test PASSED.".getBytes());
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   240
        }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   241
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   242
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   243
    public static class TestParameters {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   244
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   245
        final String cipherSuite;
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   246
        final String protocol;
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   247
        final String clientAuth;
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   248
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   249
        TestParameters(String cipherSuite, String protocol, String clientAuth) {
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   250
            this.cipherSuite = cipherSuite;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   251
            this.protocol = protocol;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   252
            this.clientAuth = clientAuth;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   253
        }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   254
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   255
        boolean isEnabled() {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   256
            return true;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   257
        }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   258
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   259
        @Override
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   260
        public String toString() {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   261
            String s = cipherSuite + " in " + protocol + " mode";
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   262
            if (clientAuth != null) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   263
                s += " with " + clientAuth + " client authentication";
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   264
            }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   265
            return s;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   266
        }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   267
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   268
27180
8c2a590d464f 8061464: A typo in CipherTestUtils test
xuelei
parents: 26337
diff changeset
   269
    private static volatile CipherTestUtils instance = null;
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   270
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   271
    public static CipherTestUtils getInstance() throws Exception {
27180
8c2a590d464f 8061464: A typo in CipherTestUtils test
xuelei
parents: 26337
diff changeset
   272
        if (instance == null) {
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   273
            synchronized (CipherTestUtils.class) {
27180
8c2a590d464f 8061464: A typo in CipherTestUtils test
xuelei
parents: 26337
diff changeset
   274
                if (instance == null) {
8c2a590d464f 8061464: A typo in CipherTestUtils test
xuelei
parents: 26337
diff changeset
   275
                    instance = new CipherTestUtils();
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   276
                }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   277
            }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   278
        }
27180
8c2a590d464f 8061464: A typo in CipherTestUtils test
xuelei
parents: 26337
diff changeset
   279
        return instance;
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   280
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   281
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   282
    public static void setTestedArguments(String protocol, String ciphersuite) {
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   283
        ciphersuite = ciphersuite.trim();
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   284
        TestParameters params = new TestParameters(ciphersuite, protocol, null);
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   285
        TESTS.add(params);
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   286
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   287
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   288
    public X509ExtendedKeyManager getClientKeyManager() {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   289
        return clientKeyManager;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   290
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   291
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   292
    public X509TrustManager getClientTrustManager() {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   293
        return clientTrustManager;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   294
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   295
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   296
    public X509ExtendedKeyManager getServerKeyManager() {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   297
        return serverKeyManager;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   298
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   299
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   300
    public X509TrustManager getServerTrustManager() {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   301
        return serverTrustManager;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   302
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   303
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   304
    public static void addFailure(Exception e) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   305
        EXCEPTIONS.add(e);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   306
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   307
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   308
    private CipherTestUtils() throws Exception {
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   309
        factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   310
        KeyStore serverKeyStore = createServerKeyStore(SERVER_PUBLIC_KEY,
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   311
                SERVER_PRIVATE_KEY);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   312
        KeyStore serverTrustStore = createServerKeyStore(CA_PUBLIC_KEY,
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   313
                CA_PRIVATE_KEY);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   314
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   315
        if (serverKeyStore != null) {
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   316
            KeyManagerFactory keyFactory = KeyManagerFactory.getInstance(
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   317
                            KeyManagerFactory.getDefaultAlgorithm());
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   318
            keyFactory.init(serverKeyStore, PASSWORD);
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   319
            serverKeyManager = (X509ExtendedKeyManager)
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   320
                    keyFactory.getKeyManagers()[0];
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   321
        } else {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   322
            serverKeyManager = null;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   323
        }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   324
        serverTrustManager = serverTrustStore != null
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   325
                ? new AlwaysTrustManager(serverTrustStore) : null;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   326
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   327
        KeyStore clientKeyStore, clientTrustStore;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   328
        clientTrustStore = serverTrustStore;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   329
        clientKeyStore =
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   330
                createServerKeyStore(CLIENT_PUBLIC_KEY,CLIENT_PRIVATE_KEY);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   331
        if (clientKeyStore != null) {
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   332
            KeyManagerFactory keyFactory = KeyManagerFactory.getInstance(
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   333
                            KeyManagerFactory.getDefaultAlgorithm());
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   334
            keyFactory.init(clientKeyStore, PASSWORD);
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   335
            clientKeyManager = (X509ExtendedKeyManager)
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   336
                    keyFactory.getKeyManagers()[0];
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   337
        } else {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   338
            clientKeyManager = null;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   339
        }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   340
        clientTrustManager = (clientTrustStore != null)
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   341
                ? new AlwaysTrustManager(clientTrustStore) : null;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   342
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   343
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   344
    void checkResult(String exception) throws Exception {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   345
        if (EXCEPTIONS.size() >= 1) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   346
            Exception actualException = EXCEPTIONS.get(0);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   347
            if (exception == null) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   348
                throw new RuntimeException("FAILED: got unexpected exception: "
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   349
                        + actualException);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   350
            }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   351
            if (!exception.equals(actualException.getClass().getName())) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   352
                throw new RuntimeException("FAILED: got unexpected exception: "
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   353
                        + actualException);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   354
            }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   355
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   356
            System.out.println("PASSED: got expected exception: "
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   357
                    + actualException);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   358
        } else {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   359
            if (exception != null) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   360
                throw new RuntimeException("FAILED: " + exception
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   361
                        + " was expected");
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   362
            }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   363
            System.out.println("PASSED");
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   364
        }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   365
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   366
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   367
    SSLSocketFactory getFactory() {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   368
        return factory;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   369
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   370
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   371
    static abstract class Client implements Runnable {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   372
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   373
        final CipherTestUtils cipherTest;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   374
        TestParameters testedParams;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   375
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   376
        Client(CipherTestUtils cipherTest) throws Exception {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   377
            this.cipherTest = cipherTest;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   378
        }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   379
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   380
        Client(CipherTestUtils cipherTest, String testedCipherSuite)
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   381
                throws Exception {
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   382
            this.cipherTest = cipherTest;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   383
        }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   384
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   385
        @Override
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   386
        public final void run() {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   387
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   388
            TESTS.stream().map((params) -> {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   389
                if (!params.isEnabled()) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   390
                    System.out.println("Skipping disabled test " + params);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   391
                }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   392
                return params;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   393
            }).forEach((params) -> {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   394
                try {
30904
ec0224270f90 8043758: Datagram Transport Layer Security (DTLS)
xuelei
parents: 27180
diff changeset
   395
                    System.out.println("Testing " + params);
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   396
                    runTest(params);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   397
                    System.out.println("Passed " + params);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   398
                } catch (Exception e) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   399
                    CipherTestUtils.addFailure(e);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   400
                    System.out.println("** Failed " + params
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   401
                            + "**, got exception:");
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   402
                    e.printStackTrace(System.out);
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   403
                }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   404
            });
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   405
        }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   406
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   407
        abstract void runTest(TestParameters params) throws Exception;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   408
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   409
        void sendRequest(InputStream in, OutputStream out) throws IOException {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   410
            out.write("GET / HTTP/1.0\r\n\r\n".getBytes());
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   411
            out.flush();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   412
            StringBuilder sb = new StringBuilder();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   413
            while (true) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   414
                int ch = in.read();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   415
                if (ch < 0) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   416
                    break;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   417
                }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   418
                sb.append((char) ch);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   419
            }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   420
            String response = sb.toString();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   421
            if (response.startsWith("HTTP/1.0 200 ") == false) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   422
                throw new IOException("Invalid response: " + response);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   423
            } else {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   424
                System.out.println();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   425
                System.out.println("--- Response --- ");
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   426
                System.out.println(response);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   427
                System.out.println("---------------- ");
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   428
            }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   429
        }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   430
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   431
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   432
    public static void printStringArray(String[] stringArray) {
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   433
        System.out.println(Arrays.toString(stringArray));
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   434
        System.out.println();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   435
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   436
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   437
    public static void printInfo(SSLServerSocket socket) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   438
        System.out.println();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   439
        System.out.println("--- SSL ServerSocket Info ---");
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   440
        System.out.print("SupportedProtocols    : ");
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   441
        printStringArray(socket.getSupportedProtocols());
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   442
        System.out.print("SupportedCipherSuites : ");
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   443
        printStringArray(socket.getSupportedCipherSuites());
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   444
        System.out.print("EnabledProtocols      : ");
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   445
        printStringArray(socket.getEnabledProtocols());
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   446
        System.out.print("EnabledCipherSuites   : ");
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   447
        String[] supportedCipherSuites = socket.getEnabledCipherSuites();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   448
        Arrays.sort(supportedCipherSuites);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   449
        printStringArray(supportedCipherSuites);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   450
        System.out.println("NeedClientAuth        : "
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   451
                + socket.getNeedClientAuth());
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   452
        System.out.println("WantClientAuth        : "
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   453
                + socket.getWantClientAuth());
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   454
        System.out.println("-----------------------");
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   455
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   456
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   457
    public static void printInfo(SSLSocket socket) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   458
        System.out.println();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   459
        System.out.println("--- SSL Socket Info ---");
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   460
        System.out.print(" SupportedProtocols    : ");
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   461
        printStringArray(socket.getSupportedProtocols());
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   462
        System.out.println(" EnabledProtocols      : "
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   463
                + socket.getEnabledProtocols()[0]);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   464
        System.out.print(" SupportedCipherSuites : ");
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   465
        String[] supportedCipherSuites = socket.getEnabledCipherSuites();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   466
        Arrays.sort(supportedCipherSuites);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   467
        printStringArray(supportedCipherSuites);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   468
        System.out.println(" EnabledCipherSuites   : "
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   469
                + socket.getEnabledCipherSuites()[0]);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   470
        System.out.println(" NeedClientAuth        : "
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   471
                + socket.getNeedClientAuth());
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   472
        System.out.println(" WantClientAuth        : "
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   473
                + socket.getWantClientAuth());
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   474
        System.out.println("-----------------------");
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   475
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   476
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   477
    private static KeyStore createServerKeyStore(String publicKey,
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   478
            String keySpecStr) throws KeyStoreException, IOException,
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   479
            NoSuchAlgorithmException, CertificateException,
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   480
            InvalidKeySpecException {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   481
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   482
        KeyStore ks = KeyStore.getInstance("JKS");
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   483
        ks.load(null, null);
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   484
        if (publicKey == null || keySpecStr == null) {
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   485
            throw new IllegalArgumentException("publicKey or "
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   486
                    + "keySpecStr cannot be null");
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   487
        }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   488
        String strippedPrivateKey = keySpecStr.substring(
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   489
                keySpecStr.indexOf("\n"), keySpecStr.lastIndexOf("\n"));
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   490
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   491
        // generate the private key.
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   492
        PKCS8EncodedKeySpec priKeySpec = new PKCS8EncodedKeySpec(
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   493
                Base64.getMimeDecoder().decode(strippedPrivateKey));
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   494
        KeyFactory kf = KeyFactory.getInstance("RSA");
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   495
        RSAPrivateKey priKey
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   496
                = (RSAPrivateKey) kf.generatePrivate(priKeySpec);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   497
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   498
        // generate certificate chain
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   499
        try (InputStream is = new ByteArrayInputStream(publicKey.getBytes())) {
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   500
            // generate certificate from cert string
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   501
            CertificateFactory cf = CertificateFactory.getInstance("X.509");
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   502
            Certificate keyCert = cf.generateCertificate(is);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   503
            Certificate[] chain = {keyCert};
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   504
            ks.setKeyEntry("TestEntry", priKey, PASSWORD, chain);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   505
        }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   506
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   507
        return ks;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   508
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   509
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   510
    public static Server mainServer(PeerFactory peerFactory,
38430
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   511
            String expectedException) throws Exception {
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   512
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   513
        setTestedArguments(peerFactory.getTestedProtocol(),
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   514
                peerFactory.getTestedCipher());
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   515
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   516
        System.out.print(
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   517
                " Initializing test '" + peerFactory.getName() + "'...");
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   518
        secureRandom.nextInt();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   519
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   520
        CipherTestUtils cipherTest = CipherTestUtils.getInstance();
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   521
        Server srv = peerFactory.newServer(cipherTest, PeerFactory.FREE_PORT);
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   522
        Thread serverThread = new Thread(srv, "Server");
38430
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   523
        serverThread.start();
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   524
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   525
        return srv;
38430
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   526
    }
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   527
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   528
    public static void mainClient(PeerFactory peerFactory, int port,
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   529
            String expectedException) throws Exception {
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   530
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   531
        long time = System.currentTimeMillis();
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   532
        setTestedArguments(peerFactory.getTestedProtocol(),
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   533
                peerFactory.getTestedCipher());
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   534
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   535
        System.out.print(
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   536
                " Initializing test '" + peerFactory.getName() + "'...");
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   537
        secureRandom.nextInt();
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   538
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   539
        CipherTestUtils cipherTest = CipherTestUtils.getInstance();
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   540
        peerFactory.newClient(cipherTest, port).run();
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   541
        cipherTest.checkResult(expectedException);
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   542
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   543
        time = System.currentTimeMillis() - time;
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   544
        System.out.println("Elapsed time " + time);
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   545
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   546
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   547
    public static abstract class PeerFactory {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   548
38430
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   549
        public static final int FREE_PORT = 0;
e8d1995c38fa 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use
asmotrak
parents: 31419
diff changeset
   550
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   551
        abstract String getName();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   552
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   553
        abstract String getTestedProtocol();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   554
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   555
        abstract String getTestedCipher();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   556
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   557
        abstract Client newClient(CipherTestUtils cipherTest, int testPort)
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   558
                throws Exception;
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   559
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   560
        abstract Server newServer(CipherTestUtils cipherTest, int testPort)
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   561
                throws Exception;
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   562
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   563
        boolean isSupported(String cipherSuite) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   564
            return true;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   565
        }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   566
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   567
}
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   568
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   569
class AlwaysTrustManager implements X509TrustManager {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   570
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   571
    X509TrustManager trustManager;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   572
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   573
    public AlwaysTrustManager(KeyStore keyStore)
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   574
            throws NoSuchAlgorithmException, KeyStoreException {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   575
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   576
        TrustManagerFactory tmf
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   577
                = TrustManagerFactory.getInstance(TrustManagerFactory.
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   578
                        getDefaultAlgorithm());
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   579
        tmf.init(keyStore);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   580
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   581
        TrustManager tms[] = tmf.getTrustManagers();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   582
        for (TrustManager tm : tms) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   583
            trustManager = (X509TrustManager) tm;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   584
            return;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   585
        }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   586
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   587
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   588
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   589
    @Override
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   590
    public void checkClientTrusted(X509Certificate[] chain, String authType)
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   591
            throws CertificateException {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   592
        try {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   593
            trustManager.checkClientTrusted(chain, authType);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   594
        } catch (CertificateException excep) {
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   595
            System.out.println("ERROR in client trust manager: " + excep);
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   596
        }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   597
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   598
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   599
    @Override
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   600
    public void checkServerTrusted(X509Certificate[] chain, String authType)
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   601
            throws CertificateException {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   602
        try {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   603
            trustManager.checkServerTrusted(chain, authType);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   604
        } catch (CertificateException excep) {
39140
86f21a96d0ab 8152745: javax/net/ssl/TLS/TestJSSE.java fails intermittently: Unsupported or unrecognized SSL message
asmotrak
parents: 38430
diff changeset
   605
            System.out.println("ERROR in server trust manager: " + excep);
26337
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   606
        }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   607
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   608
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   609
    @Override
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   610
    public X509Certificate[] getAcceptedIssuers() {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   611
        return trustManager.getAcceptedIssuers();
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   612
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   613
}
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   614
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   615
class MyX509KeyManager extends X509ExtendedKeyManager {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   616
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   617
    private final X509ExtendedKeyManager keyManager;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   618
    private String authType;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   619
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   620
    MyX509KeyManager(X509ExtendedKeyManager keyManager) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   621
        this.keyManager = keyManager;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   622
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   623
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   624
    void setAuthType(String authType) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   625
        this.authType = "ECDSA".equals(authType) ? "EC" : authType;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   626
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   627
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   628
    @Override
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   629
    public String[] getClientAliases(String keyType, Principal[] issuers) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   630
        if (authType == null) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   631
            return null;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   632
        }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   633
        return keyManager.getClientAliases(authType, issuers);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   634
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   635
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   636
    @Override
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   637
    public String chooseClientAlias(String[] keyType, Principal[] issuers,
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   638
            Socket socket) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   639
        if (authType == null) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   640
            return null;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   641
        }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   642
        return keyManager.chooseClientAlias(new String[]{authType},
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   643
                issuers, socket);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   644
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   645
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   646
    @Override
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   647
    public String chooseEngineClientAlias(String[] keyType,
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   648
            Principal[] issuers, SSLEngine engine) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   649
        if (authType == null) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   650
            return null;
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   651
        }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   652
        return keyManager.chooseEngineClientAlias(new String[]{authType},
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   653
                issuers, engine);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   654
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   655
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   656
    @Override
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   657
    public String[] getServerAliases(String keyType, Principal[] issuers) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   658
        throw new UnsupportedOperationException("Servers not supported");
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   659
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   660
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   661
    @Override
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   662
    public String chooseServerAlias(String keyType, Principal[] issuers,
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   663
            Socket socket) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   664
        throw new UnsupportedOperationException("Servers not supported");
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   665
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   666
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   667
    @Override
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   668
    public String chooseEngineServerAlias(String keyType, Principal[] issuers,
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   669
            SSLEngine engine) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   670
        throw new UnsupportedOperationException("Servers not supported");
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   671
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   672
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   673
    @Override
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   674
    public X509Certificate[] getCertificateChain(String alias) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   675
        return keyManager.getCertificateChain(alias);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   676
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   677
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   678
    @Override
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   679
    public PrivateKey getPrivateKey(String alias) {
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   680
        return keyManager.getPrivateKey(alias);
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   681
    }
39f3ee5364e5 8049429: Tests for java client server communications with various TLS/SSL combinations.
xuelei
parents:
diff changeset
   682
}