author | chegar |
Fri, 09 Mar 2018 16:52:31 +0000 | |
branch | http-client-branch |
changeset 56270 | 5c861402c69e |
parent 56265 | ec34ae013fbe |
child 56272 | 7394452786ba |
permissions | -rw-r--r-- |
56126
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
1 |
/* |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
4 |
* |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
8 |
* |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
13 |
* accompanied this code). |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
14 |
* |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
18 |
* |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
21 |
* questions. |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
22 |
*/ |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
23 |
|
56270
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
24 |
import java.io.File; |
56126
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
25 |
import java.net.URI; |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
26 |
import java.net.http.HttpClient; |
56270
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
27 |
import java.net.http.HttpResponse.BodyHandlers; |
56126
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
28 |
import java.net.http.HttpRequest; |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
29 |
import java.net.http.HttpResponse; |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
30 |
import javax.net.ssl.SSLContext; |
56270
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
31 |
import javax.net.ssl.SSLException; |
56126
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
32 |
import javax.net.ssl.SSLParameters; |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
33 |
|
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
34 |
/* |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
35 |
* @test |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
36 |
* @build Server CertificateTest |
56270
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
37 |
* @run main/othervm CertificateTest good.keystore expectSuccess |
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
38 |
* @run main/othervm CertificateTest bad.keystore expectFailure |
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
39 |
* @run main/othervm |
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
40 |
* -Djdk.internal.http.disableHostnameVerification |
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
41 |
* CertificateTest bad.keystore expectSuccess |
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
42 |
* @run main/othervm |
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
43 |
* -Djdk.internal.http.disableHostnameVerification=true |
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
44 |
* CertificateTest bad.keystore expectSuccess |
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
45 |
* @run main/othervm |
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
46 |
* -Djdk.internal.http.disableHostnameVerification=false |
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
47 |
* CertificateTest bad.keystore expectFailure |
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
48 |
* @run main/othervm |
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
49 |
* -Djdk.internal.http.disableHostnameVerification=xxyyzz |
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
50 |
* CertificateTest bad.keystore expectFailure |
56126
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
51 |
*/ |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
52 |
|
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
53 |
/** |
56270
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
54 |
* The test runs a number of times. In all cases it uses a valid self-signed certificate |
56126
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
55 |
* that is installed in the trust store (so is trusted) and the same cert is supplied |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
56 |
* by the server for its own identity. Two servers on two different ports are used |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
57 |
* on the remote end. |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
58 |
* |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
59 |
* For the "good" run the cert contains the correct hostname of the target server |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
60 |
* and therefore should be accepted by the cert checking code in the client. |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
61 |
* For the "bad" run, the cert contains an invalid hostname, and should be rejected. |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
62 |
*/ |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
63 |
public class CertificateTest { |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
64 |
static SSLContext ctx; |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
65 |
static SSLParameters params; |
56270
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
66 |
static boolean expectSuccess; |
56126
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
67 |
static String trustStoreProp; |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
68 |
static Server server; |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
69 |
static int port; |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
70 |
|
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
71 |
static String TESTSRC = System.getProperty("test.src"); |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
72 |
public static void main(String[] args) throws Exception |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
73 |
{ |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
74 |
try { |
56270
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
75 |
String keystore = args[0]; |
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
76 |
trustStoreProp = TESTSRC + File.separatorChar + keystore; |
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
77 |
|
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
78 |
String passOrFail = args[1]; |
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
79 |
|
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
80 |
if (passOrFail.equals("expectSuccess")) { |
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
81 |
expectSuccess = true; |
56126
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
82 |
} else { |
56270
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
83 |
expectSuccess = false; |
56126
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
84 |
} |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
85 |
server = new Server(trustStoreProp); |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
86 |
port = server.getPort(); |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
87 |
System.setProperty("javax.net.ssl.trustStore", trustStoreProp); |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
88 |
System.setProperty("javax.net.ssl.trustStorePassword", "passphrase"); |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
89 |
init(); |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
90 |
test(args); |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
91 |
} finally { |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
92 |
server.stop(); |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
93 |
} |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
94 |
} |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
95 |
|
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
96 |
static void init() throws Exception |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
97 |
{ |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
98 |
ctx = SSLContext.getDefault(); |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
99 |
params = ctx.getDefaultSSLParameters(); |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
100 |
//params.setProtocols(new String[] { "TLSv1.2" }); |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
101 |
} |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
102 |
|
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
103 |
static void test(String[] args) throws Exception |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
104 |
{ |
56265
ec34ae013fbe
http-client-branch: tests should bind to the loopback only
chegar
parents:
56167
diff
changeset
|
105 |
String uri_s = "https://localhost:" + Integer.toString(port) + "/foo"; |
56126
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
106 |
String error = null; |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
107 |
Exception exception = null; |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
108 |
System.out.println("Making request to " + uri_s); |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
109 |
HttpClient client = HttpClient.newBuilder() |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
110 |
.sslContext(ctx) |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
111 |
.sslParameters(params) |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
112 |
.build(); |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
113 |
|
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
114 |
HttpRequest request = HttpRequest.newBuilder(new URI(uri_s)) |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
115 |
.version(HttpClient.Version.HTTP_1_1) |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
116 |
.GET() |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
117 |
.build(); |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
118 |
|
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
119 |
try { |
56270
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
120 |
HttpResponse<String> response = client.send(request, BodyHandlers.ofString()); |
56126
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
121 |
System.out.printf("Status code %d received\n", response.statusCode()); |
56270
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
122 |
if (expectSuccess && response.statusCode() != 200) |
56126
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
123 |
error = "Test failed: good: status should be 200"; |
56270
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
124 |
else if (!expectSuccess) |
56126
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
125 |
error = "Test failed: bad: status should not be 200"; |
56270
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
126 |
} catch (SSLException e) { |
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
127 |
System.err.println("Caught Exception " + e + ". expectSuccess = " + expectSuccess); |
56126
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
128 |
exception = e; |
56270
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
129 |
if (expectSuccess) |
5c861402c69e
http-client-branch: test update for disableHostnameVerification
chegar
parents:
56265
diff
changeset
|
130 |
error = "Test failed: expectSuccess:true, but got unexpected exception"; |
56126
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
131 |
} |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
132 |
if (error != null) |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
133 |
throw new RuntimeException(error, exception); |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
134 |
} |
86e628130926
http-client-branch: fixed TLS hostname checking issue, SSL session reuse, and changed HttpResponse to return SSLSession
michaelm
parents:
diff
changeset
|
135 |
} |