testSessionTickets() — netty Function Reference
Architecture documentation for the testSessionTickets() function in SslHandlerTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD c336ec7d_c831_ae03_d66e_7f5ab62b3193["testSessionTickets()"] adaf7dc7_94e2_152f_ffdb_453fdaa4f25e["SslHandlerTest"] c336ec7d_c831_ae03_d66e_7f5ab62b3193 -->|defined in| adaf7dc7_94e2_152f_ffdb_453fdaa4f25e 071708ca_de7e_4ade_5ea8_95b025026c08["testSessionTicketsWithTLSv12()"] 071708ca_de7e_4ade_5ea8_95b025026c08 -->|calls| c336ec7d_c831_ae03_d66e_7f5ab62b3193 cd506a01_12a5_c87d_bb9c_a4e505e0dd60["testSessionTicketsWithTLSv13()"] cd506a01_12a5_c87d_bb9c_a4e505e0dd60 -->|calls| c336ec7d_c831_ae03_d66e_7f5ab62b3193 421b3c2a_4a26_841a_34c9_cafbc5157e97["testSessionTicketsWithTLSv12AndNoKey()"] 421b3c2a_4a26_841a_34c9_cafbc5157e97 -->|calls| c336ec7d_c831_ae03_d66e_7f5ab62b3193 2bd6de79_1971_0b28_8099_03ed7b930a39["testSessionTicketsWithTLSv13AndNoKey()"] 2bd6de79_1971_0b28_8099_03ed7b930a39 -->|calls| c336ec7d_c831_ae03_d66e_7f5ab62b3193 0fd148d9_de21_9e3d_3bde_be07148f32de["userEventTriggered()"] c336ec7d_c831_ae03_d66e_7f5ab62b3193 -->|calls| 0fd148d9_de21_9e3d_3bde_be07148f32de style c336ec7d_c831_ae03_d66e_7f5ab62b3193 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java lines 1281–1374
private static void testSessionTickets(SslProvider provider, String protocol, boolean withKey) throws Throwable {
OpenSsl.ensureAvailability();
final SslContext sslClientCtx = SslContextBuilder.forClient()
.trustManager(InsecureTrustManagerFactory.INSTANCE)
.sslProvider(provider)
.protocols(protocol)
.build();
// Explicit enable session cache as it's disabled by default atm.
((ReferenceCountedOpenSslContext) sslClientCtx).sessionContext()
.setSessionCacheEnabled(true);
final SelfSignedCertificate cert = CachedSelfSignedCertificate.getCachedCertificate();
final SslContext sslServerCtx = SslContextBuilder.forServer(cert.key(), cert.cert())
.sslProvider(provider)
.protocols(protocol)
.build();
if (withKey) {
OpenSslSessionTicketKey key = new OpenSslSessionTicketKey(new byte[OpenSslSessionTicketKey.NAME_SIZE],
new byte[OpenSslSessionTicketKey.HMAC_KEY_SIZE], new byte[OpenSslSessionTicketKey.AES_KEY_SIZE]);
((OpenSslSessionContext) sslClientCtx.sessionContext()).setTicketKeys(key);
((OpenSslSessionContext) sslServerCtx.sessionContext()).setTicketKeys(key);
} else {
((OpenSslSessionContext) sslClientCtx.sessionContext()).setTicketKeys();
((OpenSslSessionContext) sslServerCtx.sessionContext()).setTicketKeys();
}
EventLoopGroup group = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());
Channel sc = null;
final byte[] bytes = new byte[96];
ThreadLocalRandom.current().nextBytes(bytes);
try {
final AtomicReference<AssertionError> assertErrorRef = new AtomicReference<AssertionError>();
sc = new ServerBootstrap()
.group(group)
.channel(NioServerSocketChannel.class)
.childHandler(new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel ch) {
final SslHandler sslHandler = sslServerCtx.newHandler(ch.alloc());
ch.pipeline().addLast(sslServerCtx.newHandler(UnpooledByteBufAllocator.DEFAULT));
ch.pipeline().addLast(new ChannelInboundHandlerAdapter() {
private int handshakeCount;
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
if (evt instanceof SslHandshakeCompletionEvent) {
handshakeCount++;
ReferenceCountedOpenSslEngine engine =
(ReferenceCountedOpenSslEngine) sslHandler.engine();
// This test only works for non TLSv1.3 as TLSv1.3 will establish sessions after
// the handshake is done.
// See https://www.openssl.org/docs/man1.1.1/man3/SSL_CTX_sess_set_get_cb.html
if (!SslProtocols.TLS_v1_3.equals(engine.getSession().getProtocol())) {
// First should not re-use the session
try {
assertEquals(handshakeCount > 1, engine.isSessionReused());
} catch (AssertionError error) {
assertErrorRef.set(error);
return;
}
}
ctx.writeAndFlush(Unpooled.wrappedBuffer(bytes));
}
}
@Override
public void handlerRemoved(ChannelHandlerContext ctx) {
ReferenceCountUtil.release(sslHandler.engine());
}
});
}
})
.bind(new InetSocketAddress(0)).syncUninterruptibly().channel();
InetSocketAddress serverAddr = (InetSocketAddress) sc.localAddress();
testSessionTickets(serverAddr, group, sslClientCtx, bytes, false);
testSessionTickets(serverAddr, group, sslClientCtx, bytes, true);
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does testSessionTickets() do?
testSessionTickets() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java.
Where is testSessionTickets() defined?
testSessionTickets() is defined in handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java at line 1281.
What does testSessionTickets() call?
testSessionTickets() calls 1 function(s): userEventTriggered.
What calls testSessionTickets()?
testSessionTickets() is called by 4 function(s): testSessionTicketsWithTLSv12, testSessionTicketsWithTLSv12AndNoKey, testSessionTicketsWithTLSv13, testSessionTicketsWithTLSv13AndNoKey.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free