httpclient发送https请求
主要是创建CloseableHttpClient对象时设置一些东西
public static CloseableHttpClient createHttpsClient() throws Exception {
SSLContext sslContext = new SSLContextBuilder()
.loadTrustMaterial(null,new TrustStrategy() {
@Override
public boolean isTrusted(X509Certificate[] x509Certificates,String s)
throws CertificateException {
// 直接返回true 不做任何验证
return true;
}
})
.build();
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext);
return HttpClients.custom()
.setSSLSocketFactory(sslsf)
.build();
}
不知道什么意思,英文的看不懂。。。
的loadTrustMaterial方法还有很多重载,也不太懂