HttpClient4.3 about SSL Certificate requests in https
HttpClient4.3 concerning the SSL certificate request in https, go directly to the code here and use the CloseableHttpClient implementation class.
Call this method to create CloseableHttpClient to trust all https SSL certificates
Allow all host names in SSLConnectionSocketFactory to ignore host name verification.
Private static CloseableHttpClient buildSSLCloseableHttpClient () throws Exception {
SSLContext sslContext = new SSLContextBuilder (). loadTrustMaterial (null, new TrustStrategy (){
// Trust all
Public boolean isTrusted (X509Certificate [] chain, String authType) throws CertificateException {
Return true;
}
}). Build ();
// ALLOW_ALL_HOSTNAME_VERIFIER: This host name validator basically disables host name verification and implements an empty operation without throwing a javax.net. ssl. SSLException exception.
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory (sslContext, new String [] {"TLSv1"}, null,
SSLConnectionSocketFactory. ALLOW_ALL_HOSTNAME_VERIFIER );
Return HttpClients. custom (). setSSLSocketFactory (sslsf). build ();
}
Upgrade HttpClient4 from HttpClient3 to HttpClient4
HttpClient tutorial
Use HttpClient to upload and download files
HttpClient for Android requests Https
Android uses HttpClient to download images
HttpClient usage
This article permanently updates the link address: