|
32 | 32 |
|
33 | 33 | import javax.net.ssl.HttpsURLConnection; |
34 | 34 | import javax.net.ssl.SSLContext; |
| 35 | +import javax.net.ssl.SSLParameters; |
| 36 | +import javax.net.ssl.SSLSocket; |
35 | 37 | import javax.net.ssl.TrustManager; |
36 | 38 | import javax.net.ssl.X509TrustManager; |
37 | 39 |
|
@@ -194,12 +196,26 @@ public static DefaultHttpClient getNewHttpClient(KeyStore keyStore) { |
194 | 196 |
|
195 | 197 | @Override |
196 | 198 | public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException { |
197 | | - return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose); |
| 199 | + Socket localSocket = sslContext.getSocketFactory().createSocket(socket, host, port, autoClose); |
| 200 | + enableSecureProtocols(localSocket); |
| 201 | + return localSocket; |
198 | 202 | } |
199 | 203 |
|
200 | 204 | @Override |
201 | 205 | public Socket createSocket() throws IOException { |
202 | | - return sslContext.getSocketFactory().createSocket(); |
| 206 | + Socket socket = sslContext.getSocketFactory().createSocket(); |
| 207 | + enableSecureProtocols(socket); |
| 208 | + return socket; |
| 209 | + } |
| 210 | + |
| 211 | + /** |
| 212 | + * Activate supported protocols on the socket. |
| 213 | + * @param socket The socket on which to activate secure protocols. |
| 214 | + */ |
| 215 | + private void enableSecureProtocols(Socket socket) { |
| 216 | + // set all supported protocols |
| 217 | + SSLParameters params = sslContext.getSupportedSSLParameters(); |
| 218 | + ((SSLSocket) socket).setEnabledProtocols(params.getProtocols()); |
203 | 219 | } |
204 | 220 |
|
205 | 221 | /** |
|
0 commit comments