SNISupport - Httpcomponents Wiki - 0 views
-
"SSLContext sslcontext = SSLContexts.createSystemDefault(); 2 SSLSocketFactory sslsf = new SSLSocketFactory(sslcontext) { 3 4 @Override 5 public Socket connectSocket( 6 int connectTimeout, 7 Socket socket, 8 HttpHost host, 9 InetSocketAddress remoteAddress, 10 InetSocketAddress localAddress, 11 HttpContext context) throws IOException, ConnectTimeoutException { 12 if (socket instanceof SSLSocket) { 13 try { 14 PropertyUtils.setProperty(socket, "host", host.getHostName()); 15 } catch (NoSuchMethodException ex) { 16 } catch (IllegalAccessException ex) { 17 } catch (InvocationTargetException ex) { 18 } 19 } 20 return super.connectSocket(connectTimeout, socket, host, remoteAddress, 21 localAddress, context); 22 } 23 24 }; 25 26 CloseableHttpClient httpclient = HttpClients.custom() 27 .setSSLSocketFactory(sslsf) 28 .build(); 29 CloseableHttpResponse response = httpclient.execute(new HttpGet("https://verisign.com/")); 30 try { 31 System.out.println(response.getStatusLine()); 32 EntityUtils.consume(response.getEntity()); 33 } finally { 34 response.close(); 35 }"
1 - 2 of 2
Showing 20▼ items per page