use of org.apache.http.conn.ssl.NoopHostnameVerifier in project wildfly by wildfly.
the class WebSecurityCERTTestCase method getHttpsClient.
private static CloseableHttpClient getHttpsClient(String alias) {
try {
SSLContext ctx = SSLContext.getInstance("TLS");
JBossJSSESecurityDomain jsseSecurityDomain = new JBossJSSESecurityDomain("client-cert");
jsseSecurityDomain.setKeyStorePassword("changeit");
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
URL keystore = tccl.getResource("security/client.keystore");
jsseSecurityDomain.setKeyStoreURL(keystore.getPath());
jsseSecurityDomain.setClientAlias(alias);
jsseSecurityDomain.reloadKeyAndTrustStore();
KeyManager[] keyManagers = jsseSecurityDomain.getKeyManagers();
TrustManager[] trustManagers = jsseSecurityDomain.getTrustManagers();
ctx.init(keyManagers, trustManagers, null);
HostnameVerifier verifier = (string, ssls) -> true;
//SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
SSLConnectionSocketFactory ssf = new SSLConnectionSocketFactory(ctx, verifier);
Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create().register("https", ssf).build();
HttpClientConnectionManager ccm = new BasicHttpClientConnectionManager(registry);
return HttpClientBuilder.create().setSSLSocketFactory(ssf).setSSLHostnameVerifier(new NoopHostnameVerifier()).setConnectionManager(ccm).build();
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
use of org.apache.http.conn.ssl.NoopHostnameVerifier in project ats-framework by Axway.
the class HttpsClient method connect.
/**
* Connect to a remote host using basic authentication.
*
* @param hostname the host to connect to
* @param userName the user name
* @param password the password for the provided user name
* @throws FileTransferException
*/
@Override
public void connect(String hostname, String userName, String password) throws FileTransferException {
super.connect(hostname, userName, password);
// trust everybody
try {
SSLContext sslContext = SslUtils.getTrustAllSSLContext();
SSLConnectionSocketFactory ssf = new SSLConnectionSocketFactory(sslContext, encryptionProtocols, cipherSuites, new NoopHostnameVerifier());
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create().register("https", ssf).build();
HttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
this.httpBuilder.setConnectionManager(connectionManager).setSchemePortResolver(new DefaultSchemePortResolver());
this.httpClient = this.httpBuilder.build();
} catch (Exception e) {
throw new FileTransferException("Error setting trust manager", e);
}
}
use of org.apache.http.conn.ssl.NoopHostnameVerifier in project microservices by pwillhan.
the class BasicHttpsSecurityApplicationTests method socketFactory.
private SSLConnectionSocketFactory socketFactory() throws Exception {
char[] password = "password".toCharArray();
KeyStore truststore = KeyStore.getInstance("PKCS12");
truststore.load(new ClassPathResource("rod.p12").getInputStream(), password);
SSLContextBuilder builder = new SSLContextBuilder();
builder.loadKeyMaterial(truststore, password);
builder.loadTrustMaterial(truststore, new TrustSelfSignedStrategy());
return new SSLConnectionSocketFactory(builder.build(), new NoopHostnameVerifier());
}
use of org.apache.http.conn.ssl.NoopHostnameVerifier in project microservices by pwillhan.
the class X509ApplicationTests method socketFactory.
private SSLConnectionSocketFactory socketFactory() throws Exception {
char[] password = "password".toCharArray();
KeyStore truststore = KeyStore.getInstance("PKCS12");
truststore.load(new ClassPathResource("rod.p12").getInputStream(), password);
SSLContextBuilder builder = new SSLContextBuilder();
builder.loadKeyMaterial(truststore, password);
builder.loadTrustMaterial(truststore, new TrustSelfSignedStrategy());
return new SSLConnectionSocketFactory(builder.build(), new NoopHostnameVerifier());
}
use of org.apache.http.conn.ssl.NoopHostnameVerifier in project syndesis-qe by syndesisio.
the class EndpointClient method createAllTrustingClient.
// Required in order to skip certificate validation
private static HttpClient createAllTrustingClient() {
HttpClient httpclient;
try {
final SSLContextBuilder builder = new SSLContextBuilder();
builder.loadTrustMaterial((TrustStrategy) (X509Certificate[] chain, String authType) -> true);
final SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build(), // needed to connections to API Provider integrations
new NoopHostnameVerifier());
httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).setMaxConnTotal(1000).setMaxConnPerRoute(1000).build();
} catch (NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) {
throw new RestClientException("Cannot create all SSL certificates trusting client", e);
}
return httpclient;
}
Aggregations