in wilma-functionaltest/src/main/java/com/epam/wilma/gepard/testclient/HttpSPostRequestSender.java [167:199]
public static CloseableHttpClient buildHttpClient(boolean isProxied, int port) throws Exception {
// TrustStrategy acceptingTrustStrategy = (cert, authType) -> true; //checkstyle cannot handle this, so using a bit more complex code below
TrustStrategy acceptingTrustStrategy = new TrustStrategy() {
@Override
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
return true;
}
};
SSLContext sslContext = SSLContextBuilder.create()
.loadTrustMaterial(acceptingTrustStrategy)
.build();
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
Registry<ConnectionSocketFactory> socketFactoryRegistry =
RegistryBuilder.<ConnectionSocketFactory>create()
.register("https", sslsf)
.register("http", new PlainConnectionSocketFactory())
.build();
BasicHttpClientConnectionManager connectionManager = new BasicHttpClientConnectionManager(socketFactoryRegistry);
HttpClientBuilder httpClientBuilder = HttpClients.custom()
.setSSLSocketFactory(sslsf)
.setConnectionManager(connectionManager);
if (isProxied) {
HttpHost proxy = new HttpHost("127.0.0.1", port);
httpClientBuilder.setProxy(proxy);
}
CloseableHttpClient httpClient = httpClientBuilder.build();
return httpClient;
}