use of io.servicetalk.transport.api.SslProvider in project servicetalk by apple.
the class SslProvidersTest method setUp.
private void setUp(SslProvider serverSslProvider, SslProvider clientSslProvider, int payloadLength) throws Exception {
payloadBody = randomString(payloadLength);
serverContext = HttpServers.forAddress(localAddress(0)).sslConfig(new ServerSslConfigBuilder(DefaultTestCerts::loadServerPem, DefaultTestCerts::loadServerKey).provider(serverSslProvider).build()).listenBlockingAndAwait((ctx, request, responseFactory) -> {
assertThat(ctx.sslSession(), is(notNullValue()));
assertThat(request.path(), is("/path"));
assertThat(request.headers().get(CONTENT_TYPE), is(TEXT_PLAIN_UTF_8));
assertThat(request.payloadBody(textSerializerUtf8()), is("request-payload-body-" + payloadBody));
return responseFactory.ok().payloadBody("response-payload-body-" + payloadBody, textSerializerUtf8());
});
client = HttpClients.forSingleAddress(serverHostAndPort(serverContext)).ioExecutor(NettyIoExecutors.createIoExecutor("client-io")).sslConfig(new ClientSslConfigBuilder(DefaultTestCerts::loadServerCAPem).peerHost(serverPemHostname()).provider(clientSslProvider).build()).buildBlocking();
}
Aggregations