首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 服务器 > Apache >

Apache HttpClient 4.3-忽略证书有关问题

2013-12-06 
Apache HttpClient 4.3-忽略证书问题SSLContextBuilder builder new SSLContextBuilder()builder.loadT

Apache HttpClient 4.3-忽略证书问题
SSLContextBuilder builder = new SSLContextBuilder(); builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory( builder.build()); CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory( sslsf).build(); HttpGet httpGet = new HttpGet("https://some-server"); CloseableHttpResponse response = httpclient.execute(httpGet); try { System.out.println(response.getStatusLine()); HttpEntity entity = response.getEntity(); EntityUtils.consume(entity); } finally { response.close(); }

?

方法转自:http://stackoverflow.com/questions/19517538/ignoring-ssl-certificate-in-apache-httpclient-4-3?lq=1

热点排行