equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
133 */ |
133 */ |
134 void doServerSide() throws Exception { |
134 void doServerSide() throws Exception { |
135 |
135 |
136 SSLServerSocketFactory sslssf = |
136 SSLServerSocketFactory sslssf = |
137 (SSLServerSocketFactory) SSLServerSocketFactory.getDefault(); |
137 (SSLServerSocketFactory) SSLServerSocketFactory.getDefault(); |
|
138 |
|
139 // doClientSide() connects to "localhost" |
|
140 InetAddress localHost = InetAddress.getByName("localhost"); |
|
141 InetSocketAddress address = new InetSocketAddress(localHost, serverPort); |
|
142 |
138 SSLServerSocket sslServerSocket = |
143 SSLServerSocket sslServerSocket = |
139 (SSLServerSocket) sslssf.createServerSocket(serverPort); |
144 (SSLServerSocket) sslssf.createServerSocket(); |
|
145 sslServerSocket.bind(address); |
140 serverPort = sslServerSocket.getLocalPort(); |
146 serverPort = sslServerSocket.getLocalPort(); |
141 |
147 |
142 String ciphers[]= { "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA" }; |
148 String ciphers[]= { "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA" }; |
143 sslServerSocket.setEnabledCipherSuites(ciphers); |
149 sslServerSocket.setEnabledCipherSuites(ciphers); |
144 |
150 |
203 |
209 |
204 // use the default hostname verifier |
210 // use the default hostname verifier |
205 |
211 |
206 URL url = new URL("https://" + "localhost:" + serverPort + |
212 URL url = new URL("https://" + "localhost:" + serverPort + |
207 "/etc/hosts"); |
213 "/etc/hosts"); |
208 URLConnection urlc = url.openConnection(); |
214 URLConnection urlc = url.openConnection(Proxy.NO_PROXY); |
209 |
215 |
210 if (!(urlc instanceof javax.net.ssl.HttpsURLConnection)) { |
216 if (!(urlc instanceof javax.net.ssl.HttpsURLConnection)) { |
211 throw new Exception( |
217 throw new Exception( |
212 "URLConnection ! instanceof javax.net.ssl.HttpsURLConnection"); |
218 "URLConnection ! instanceof javax.net.ssl.HttpsURLConnection"); |
213 } |
219 } |