use of okhttp3.mockwebserver.internal.tls.SslClient in project mapbox-events-android by mapbox.
the class MockWebServerTest method provideDefaultTelemetryClientSettings.
private TelemetryClientSettings provideDefaultTelemetryClientSettings() {
HttpUrl localUrl = obtainBaseEndpointUrl();
SslClient sslClient = SslClient.localhost();
return new TelemetryClientSettings.Builder().baseUrl(localUrl).sslSocketFactory(sslClient.socketFactory).x509TrustManager(sslClient.trustManager).hostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
}).build();
}
use of okhttp3.mockwebserver.internal.tls.SslClient in project keywhiz by square.
the class ClientUtilsTest method testSslOkHttpClientCreation.
@Test
public void testSslOkHttpClientCreation() throws Exception {
OkHttpClient sslClient = ClientUtils.sslOkHttpClient(config.getDevTrustStore(), ImmutableList.of());
assertThat(sslClient.followSslRedirects()).isFalse();
assertThat(sslClient.sslSocketFactory()).isNotNull();
assertThat(sslClient.cookieJar()).isNotNull();
java.util.List<HttpCookie> cookieList = ClientUtils.getCookieManager().getCookieStore().getCookies();
assertThat(cookieList).isEmpty();
}
use of okhttp3.mockwebserver.internal.tls.SslClient in project okhttp by square.
the class ApacheHttpClient method prepare.
@Override
public void prepare(Benchmark benchmark) {
super.prepare(benchmark);
ClientConnectionManager connectionManager = new PoolingClientConnectionManager();
if (benchmark.tls) {
SslClient sslClient = SslClient.localhost();
connectionManager.getSchemeRegistry().register(new Scheme("https", 443, new SSLSocketFactory(sslClient.sslContext)));
}
client = new DefaultHttpClient(connectionManager);
}
use of okhttp3.mockwebserver.internal.tls.SslClient in project okhttp by square.
the class Benchmark method startServer.
private MockWebServer startServer() throws IOException {
Logger.getLogger(MockWebServer.class.getName()).setLevel(Level.WARNING);
MockWebServer server = new MockWebServer();
if (tls) {
SslClient sslClient = SslClient.localhost();
server.useHttps(sslClient.socketFactory, false);
server.setProtocols(protocols);
}
final MockResponse response = newResponse();
server.setDispatcher(new Dispatcher() {
@Override
public MockResponse dispatch(RecordedRequest request) {
return response;
}
});
server.start();
return server;
}
use of okhttp3.mockwebserver.internal.tls.SslClient in project okhttp by square.
the class NettyHttpClient method prepare.
@Override
public void prepare(final Benchmark benchmark) {
this.concurrencyLevel = benchmark.concurrencyLevel;
this.targetBacklog = benchmark.targetBacklog;
ChannelInitializer<SocketChannel> channelInitializer = new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(SocketChannel channel) throws Exception {
ChannelPipeline pipeline = channel.pipeline();
if (benchmark.tls) {
SslClient sslClient = SslClient.localhost();
SSLEngine engine = sslClient.sslContext.createSSLEngine();
engine.setUseClientMode(true);
pipeline.addLast("ssl", new SslHandler(engine));
}
pipeline.addLast("codec", new HttpClientCodec());
pipeline.addLast("inflater", new HttpContentDecompressor());
pipeline.addLast("handler", new HttpChannel(channel));
}
};
bootstrap = new Bootstrap();
bootstrap.group(new NioEventLoopGroup(concurrencyLevel)).option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT).channel(NioSocketChannel.class).handler(channelInitializer);
}
Aggregations