I am getting the exception javax.net.ssl.SSLHandshakeException. I have read up you can bypass this at the coding level. Which is what I have been attempting to do. I have added NoopHostnameVerifier.INSTANCE and SSLContext to the client builder, but still getting the SSL exception.
var clientBuilder = HttpClientBuilder.create()
.setDefaultRequestConfig(RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build())
.setRedirectStrategy(new LaxRedirectStrategy())
.setDefaultCookieStore(cookieStore)
.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
.setSSLContext(createSSLContext());
private SSLContext createSSLContext() {
TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
} };
SSLContext sc = null;
try {
sc = SSLContext.getInstance ("SSL");
sc.init (null, trustAllCerts, new java.security.SecureRandom ());
} catch (KeyManagementException | NoSuchAlgorithmException e) {
e.printStackTrace ();
}
return sc;
}