use of org.apache.http.conn.ssl.NoopHostnameVerifier in project dropwizard by dropwizard.
the class JerseyClientBuilderTest method usesACustomConnectionFactoryRegistry.
@Test
void usesACustomConnectionFactoryRegistry() throws Exception {
final SSLContext ctx = SSLContext.getInstance(SSLConnectionSocketFactory.TLS);
ctx.init(null, new TrustManager[] { new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] xcs, String string) {
}
@Override
public void checkServerTrusted(X509Certificate[] xcs, String string) {
}
@Override
@Nullable
public X509Certificate[] getAcceptedIssuers() {
return null;
}
} }, null);
final Registry<ConnectionSocketFactory> customRegistry = RegistryBuilder.<ConnectionSocketFactory>create().register("http", PlainConnectionSocketFactory.getSocketFactory()).register("https", new SSLConnectionSocketFactory(ctx, new NoopHostnameVerifier())).build();
builder.using(customRegistry);
verify(apacheHttpClientBuilder).using(customRegistry);
}
use of org.apache.http.conn.ssl.NoopHostnameVerifier in project dropwizard by dropwizard.
the class JerseyClientBuilderTest method usesACustomHostnameVerifier.
@Test
void usesACustomHostnameVerifier() {
final HostnameVerifier customHostnameVerifier = new NoopHostnameVerifier();
builder.using(customHostnameVerifier);
verify(apacheHttpClientBuilder).using(customHostnameVerifier);
}
use of org.apache.http.conn.ssl.NoopHostnameVerifier in project oxAuth by GluuFederation.
the class BaseTest method createAcceptSelfSignedSocketFactory.
private static SSLConnectionSocketFactory createAcceptSelfSignedSocketFactory() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException {
// Use the TrustSelfSignedStrategy to allow Self Signed Certificates
SSLContext sslContext = SSLContextBuilder.create().loadTrustMaterial(new TrustSelfSignedStrategy()).build();
// We can optionally disable hostname verification.
// If you don't want to further weaken the security, you don't have to include this.
HostnameVerifier allowAllHosts = new NoopHostnameVerifier();
// Create an SSL Socket Factory to use the SSLContext with the trust self signed certificate strategy
// and allow all hosts verifier.
SSLConnectionSocketFactory connectionFactory = new SSLConnectionSocketFactory(sslContext, allowAllHosts);
return connectionFactory;
}
Aggregations