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