testSniClient() — netty Function Reference
Architecture documentation for the testSniClient() function in SniClientTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD b5f56e00_c555_2f1e_8389_b36b8ea4bf9c["testSniClient()"] 03760603_e76a_2487_b3a8_7faf239ef462["SniClientTest"] b5f56e00_c555_2f1e_8389_b36b8ea4bf9c -->|defined in| 03760603_e76a_2487_b3a8_7faf239ef462 f5abc307_f250_cdab_14be_a00489a9420e["testSniSNIMatcherMatchesClient()"] f5abc307_f250_cdab_14be_a00489a9420e -->|calls| b5f56e00_c555_2f1e_8389_b36b8ea4bf9c 6e9e8ebe_6e1e_b494_8130_c943cd3653dd["testSniSNIMatcherDoesNotMatchClient()"] 6e9e8ebe_6e1e_b494_8130_c943cd3653dd -->|calls| b5f56e00_c555_2f1e_8389_b36b8ea4bf9c style b5f56e00_c555_2f1e_8389_b36b8ea4bf9c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/ssl/SniClientTest.java lines 91–164
@ParameterizedTest(name = PARAMETERIZED_NAME)
@Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
@MethodSource("parameters")
public void testSniClient(SslProvider sslServerProvider, SslProvider sslClientProvider) throws Exception {
String sniHostName = "sni.netty.io";
LocalAddress address = new LocalAddress("SniClientTest");
EventLoopGroup group = new MultiThreadIoEventLoopGroup(1, LocalIoHandler.newFactory());
SelfSignedCertificate cert = CachedSelfSignedCertificate.getCachedCertificate();
SslContext sslServerContext = null;
SslContext sslClientContext = null;
Channel sc = null;
Channel cc = null;
try {
if ((sslServerProvider == SslProvider.OPENSSL || sslServerProvider == SslProvider.OPENSSL_REFCNT)
&& !OpenSsl.useKeyManagerFactory()) {
sslServerContext = SslContextBuilder.forServer(cert.certificate(), cert.privateKey())
.sslProvider(sslServerProvider)
.build();
} else {
// The used OpenSSL version does support a KeyManagerFactory, so use it.
KeyManagerFactory kmf = SniClientJava8TestUtil.newSniX509KeyManagerFactory(cert, sniHostName);
sslServerContext = SslContextBuilder.forServer(kmf)
.sslProvider(sslServerProvider)
.build();
}
final SslContext finalContext = sslServerContext;
final Promise<String> promise = group.next().newPromise();
ServerBootstrap sb = new ServerBootstrap();
sc = sb.group(group).channel(LocalServerChannel.class).childHandler(new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel ch) throws Exception {
ch.pipeline().addFirst(new SniHandler(new Mapping<String, SslContext>() {
@Override
public SslContext map(String input) {
promise.setSuccess(input);
return finalContext;
}
}));
}
}).bind(address).syncUninterruptibly().channel();
TrustManagerFactory tmf = SniClientJava8TestUtil.newSniX509TrustmanagerFactory(sniHostName);
sslClientContext = SslContextBuilder.forClient().trustManager(tmf)
.sslProvider(sslClientProvider).build();
Bootstrap cb = new Bootstrap();
SslHandler handler = new SslHandler(
sslClientContext.newEngine(ByteBufAllocator.DEFAULT, sniHostName, -1));
cc = cb.group(group).channel(LocalChannel.class).handler(handler)
.connect(address).syncUninterruptibly().channel();
assertEquals(sniHostName, promise.syncUninterruptibly().getNow());
// After we are done with handshaking getHandshakeSession() should return null.
handler.handshakeFuture().syncUninterruptibly();
assertNull(handler.engine().getHandshakeSession());
SniClientJava8TestUtil.assertSSLSession(
handler.engine().getUseClientMode(), handler.engine().getSession(), sniHostName);
} finally {
if (cc != null) {
cc.close().syncUninterruptibly();
}
if (sc != null) {
sc.close().syncUninterruptibly();
}
ReferenceCountUtil.release(sslServerContext);
ReferenceCountUtil.release(sslClientContext);
group.shutdownGracefully();
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does testSniClient() do?
testSniClient() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/SniClientTest.java.
Where is testSniClient() defined?
testSniClient() is defined in handler/src/test/java/io/netty/handler/ssl/SniClientTest.java at line 91.
What calls testSniClient()?
testSniClient() is called by 2 function(s): testSniSNIMatcherDoesNotMatchClient, testSniSNIMatcherMatchesClient.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free