use of org.apache.http.conn.ssl.SSLConnectionSocketFactory in project cdap-ingest by caskdata.
the class RestUtil method getRegistryWithDisabledCertCheck.
public static Registry<ConnectionSocketFactory> getRegistryWithDisabledCertCheck() throws KeyManagementException, NoSuchAlgorithmException {
SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, new TrustManager[] { new X509TrustManager() {
@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
@Override
public void checkClientTrusted(java.security.cert.X509Certificate[] x509Certificates, String s) throws CertificateException {
}
@Override
public void checkServerTrusted(java.security.cert.X509Certificate[] x509Certificates, String s) throws CertificateException {
}
} }, new SecureRandom());
SSLConnectionSocketFactory sf = new SSLConnectionSocketFactory(sslContext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
return RegistryBuilder.<ConnectionSocketFactory>create().register("https", sf).register("http", PlainConnectionSocketFactory.getSocketFactory()).build();
}
use of org.apache.http.conn.ssl.SSLConnectionSocketFactory in project calcite-avatica by apache.
the class CommonsHttpClientPoolCache method configureHttpsRegistry.
private static void configureHttpsRegistry(RegistryBuilder<ConnectionSocketFactory> registryBuilder, ConnectionConfig config) {
try {
SSLContext sslContext = getSSLContext(config);
final HostnameVerifier verifier = getHostnameVerifier(config.hostnameVerification());
SSLConnectionSocketFactory sslFactory = new SSLConnectionSocketFactory(sslContext, verifier);
registryBuilder.register("https", sslFactory);
} catch (Exception e) {
LOG.error("HTTPS registry configuration failed");
throw new RuntimeException(e);
}
}
use of org.apache.http.conn.ssl.SSLConnectionSocketFactory in project hazelcast by hazelcast.
the class HTTPCommunicator method newClient.
private CloseableHttpClient newClient() throws IOException {
HttpClientBuilder builder = HttpClients.custom();
if (sslEnabled) {
SSLContext sslContext;
try {
sslContext = SSLContext.getInstance(tlsProtocol);
} catch (NoSuchAlgorithmException e) {
throw new IOException(e);
}
try {
sslContext.init(clientKeyManagers, clientTrustManagers, new SecureRandom());
} catch (KeyManagementException e) {
throw new IOException(e);
}
builder.setSSLSocketFactory(new SSLConnectionSocketFactory(sslContext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER));
}
return builder.build();
}
use of org.apache.http.conn.ssl.SSLConnectionSocketFactory in project spring-boot by spring-projects.
the class RemoteHttpClientTransport method getSecureConnectionSocketFactory.
private static LayeredConnectionSocketFactory getSecureConnectionSocketFactory(DockerHost host, SslContextFactory sslContextFactory) {
String directory = host.getCertificatePath();
Assert.hasText(directory, () -> "Docker host TLS verification requires trust material location to be specified with certificate path");
SSLContext sslContext = sslContextFactory.forDirectory(directory);
return new SSLConnectionSocketFactory(sslContext);
}
use of org.apache.http.conn.ssl.SSLConnectionSocketFactory in project spring-boot by spring-projects.
the class AbstractServletWebServerFactoryTests method sslDisabled.
@Test
void sslDisabled() throws Exception {
AbstractServletWebServerFactory factory = getFactory();
Ssl ssl = getSsl(null, "password", "classpath:test.jks");
ssl.setEnabled(false);
factory.setSsl(ssl);
this.webServer = factory.getWebServer(new ServletRegistrationBean<>(new ExampleServlet(true, false), "/hello"));
this.webServer.start();
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build());
HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
assertThatExceptionOfType(SSLException.class).isThrownBy(() -> getResponse(getLocalUrl("https", "/hello"), requestFactory));
}
Aggregations