http://mayanze.com/(这里有我写的粗浅网站,欢迎留言)
4.3版本
//绕过证书请求
SSLContext sslContext = null;
X509HostnameVerifier allowAllHostnameVerifier = SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
try {
sslContext = SSLContexts.custom().loadTrustMaterial(null, new TrustStrategy() {
@Override
public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
return true;
}
}).build();
} catch (NoSuchAlgorithmException e) {
e.getStackTrace();
} catch (KeyManagementException e) {
e.getStackTrace();
} catch (KeyStoreException e) {
e.getStackTrace();
}
CloseableHttpClient httpClient = HttpClients.custom().setKeepAliveStrategy(defaultStrategy).setConnectionManager(cm).setSslcontext(sslContext).setHostnameVerifier(allowAllHostnameVerifier).build();
4.55版本