use of io.servicetalk.test.resources.DefaultTestCerts in project servicetalk by apple.
the class GrpcSslAndNonSslConnectionsTest method noSniClientDefaultServerFallbackFailExpected.
@Test
void noSniClientDefaultServerFallbackFailExpected() throws Exception {
try (ServerContext serverContext = GrpcServers.forAddress(localAddress(0)).initializeHttp(builder -> builder.sslConfig(untrustedServerConfig(), singletonMap(getLoopbackAddress().getHostName(), trustedServerConfig()))).listenAndAwait(serviceFactory());
BlockingTesterClient client = GrpcClients.forAddress(getLoopbackAddress().getHostName(), serverHostAndPort(serverContext).port()).initializeHttp(builder -> builder.sslConfig(new ClientSslConfigBuilder(DefaultTestCerts::loadServerCAPem).build()).inferPeerHost(false).inferSniHostname(false)).buildBlocking(clientFactory())) {
GrpcStatusException e = assertThrows(GrpcStatusException.class, () -> client.test(REQUEST));
assertThat(e.getCause(), instanceOf(SSLHandshakeException.class));
}
}
Aggregations