private CloseableHttpClient httpClient; private HttpContext httpContext; private HttpClientContext context;
public Login () { try { SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() { public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException { return true; } }).build(); SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext,SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); this.httpClient = HttpClients.custom().setSSLSocketFactory(sslsf).build() ; this.httpContext = new BasicHttpContext(); this.context = HttpClientContext.adapt(httpContext); } catch (Exception e) { log.error("Configuration SSL error",e.getMessage()); } }