@Test public void testNewClientWithoutCertificateCheck() { try { System.setProperty(HttpClientFactoryImpl.CLIENT_ACCESS_UNVERIFIED_PROPERTY, "true"); ObjectMapper mapper = mock(ObjectMapper.class); HttpClientConfig config = HttpClientConfig.basicConfig() .withObjectMapper(mapper); HttpClientImpl client = createClient(config); assertThat(client.getClient().hostnameVerifier().verify("", null)).isTrue(); } finally { System.clearProperty(HttpClientFactoryImpl.CLIENT_ACCESS_UNVERIFIED_PROPERTY); } }
private static OkHttpClient createClient(HttpClientConfig config) { OkHttpClient.Builder builder = new OkHttpClient.Builder(); if (config.proxySettings().isProxyUse()) { Proxy proxy = createProxy(config.proxySettings()); builder.proxy(proxy); } if (unverifiedSSLCertificate()) { builder.hostnameVerifier((s, sslSession) -> true); } return builder.build(); }
HttpClientFactoryImpl implements HttpClientFactory { private static OkHttpClient createClient(HttpClientConfig config) { OkHttpClient.Builder builder = new OkHttpClient.Builder(); if (config.proxySettings().isProxyUse()) { Proxy proxy = createProxy(config.proxySettings()); builder.proxy(proxy); } if (unverifiedSSLCertificate()) { builder.hostnameVerifier((s, sslSession) -> true); } return builder.build(); } }
HttpClientFactoryImpl implements HttpClientFactory { private static OkHttpClient createClient(HttpClientConfig config) { OkHttpClient.Builder builder = new OkHttpClient.Builder(); if (config.proxySettings().isProxyUse()) { Proxy proxy = createProxy(config.proxySettings()); builder.proxy(proxy); } if (unverifiedSSLCertificate()) { builder.hostnameVerifier((s, sslSession) -> true); } return builder.build(); }  }
HttpClientFactoryImpl implements HttpClientFactory { private static OkHttpClient createClient(HttpClientConfig config) { OkHttpClient.Builder builder = new OkHttpClient.Builder(); if (config.proxySettings().isProxyUse()) { Proxy proxy = createProxy(config.proxySettings()); builder.proxy(proxy); } if (unverifiedSSLCertificate()) { builder.hostnameVerifier((s, sslSession) -> true); } return builder.build(); }  @Override HttpClient newHttpClient(HttpClientConfig config); }
HttpClientFactoryImpl implements HttpClientFactory { private static OkHttpClient createClient(HttpClientConfig config) { OkHttpClient.Builder builder = new OkHttpClient.Builder(); if (config.proxySettings().isProxyUse()) { Proxy proxy = createProxy(config.proxySettings()); builder.proxy(proxy); } if (unverifiedSSLCertificate()) { builder.hostnameVerifier((s, sslSession) -> true); } return builder.build(); }  @Override HttpClient newHttpClient(HttpClientConfig config);  }