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 janusgraph by JanusGraph.
the class SSLConfigurationCallback method customizeHttpClient.
@Override
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
final SSLContext sslcontext;
final TrustStrategy trustStrategy = allowSelfSignedCertificates ? new TrustSelfSignedStrategy() : null;
try {
if (StringUtils.isNotEmpty(trustStoreFile)) {
sslContextBuilder.loadTrustMaterial(new File(trustStoreFile), trustStorePassword.toCharArray(), trustStrategy);
} else {
sslContextBuilder.loadTrustMaterial(trustStrategy);
}
} catch (KeyStoreException | CertificateException | NoSuchAlgorithmException e) {
throw new RuntimeException("Invalid trust store file " + trustStoreFile, e);
} catch (IOException e) {
throw new RuntimeException("Unable to load trust store data from " + trustStoreFile, e);
}
try {
if (StringUtils.isNotEmpty(keyStoreFile)) {
sslContextBuilder.loadKeyMaterial(new File(keyStoreFile), keyStorePassword.toCharArray(), keyPassword.toCharArray());
}
} catch (KeyStoreException | CertificateException | NoSuchAlgorithmException | UnrecoverableKeyException e) {
throw new RuntimeException("Invalid key store file " + keyStoreFile, e);
} catch (IOException e) {
throw new RuntimeException("Unable to load key store data from " + keyStoreFile, e);
}
try {
sslcontext = sslContextBuilder.build();
} catch (KeyManagementException | NoSuchAlgorithmException e) {
throw new RuntimeException("SSL context initialization failed", e);
}
httpClientBuilder.setSSLContext(sslcontext);
if (disableHostNameVerification) {
httpClientBuilder.setSSLHostnameVerifier(new NoopHostnameVerifier());
}
return httpClientBuilder;
}
Aggregations