use of org.apache.eventmesh.client.http.ssl.MyX509TrustManager in project incubator-eventmesh by apache.
the class AbstractHttpClient method setHttpClient.
private CloseableHttpClient setHttpClient() throws EventMeshException {
if (!eventMeshHttpClientConfig.isUseTls()) {
return HttpClients.createDefault();
}
SSLContext sslContext;
try {
// todo: config in properties file?
String protocol = System.getProperty("ssl.client.protocol", "TLSv1.2");
TrustManager[] tm = new TrustManager[] { new MyX509TrustManager() };
sslContext = SSLContext.getInstance(protocol);
sslContext.init(null, tm, new SecureRandom());
// todo: custom client pool
return HttpClients.custom().setSSLContext(sslContext).setSSLHostnameVerifier(new DefaultHostnameVerifier()).build();
} catch (Exception e) {
log.error("Error in creating HttpClient.", e);
throw new EventMeshException(e);
}
}
Aggregations