How do I bypass certificate verification errors with Apache HttpComponents HttpClient 5.1?
I've found a working solution to bypass such errors in HttpClient 4.5 that suggests customizing HttpClient
instance:
HttpClient httpClient = HttpClients
.custom()
.setSSLContext(new SSLContextBuilder().loadTrustMaterial(null, TrustAllStrategy.INSTANCE).build())
.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
.build();
But it is not applicable to HttpClient 5.1, as setSSLContext
and setSSLHostnameVerifier
methods do not exist in HttpClientBuilder
(which HttpClients.custom()
returns).