Home / Function/ testTlsConnection() — netty Function Reference

testTlsConnection() — netty Function Reference

Architecture documentation for the testTlsConnection() function in PkiTestingTlsTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  a8eac5c5_344b_7e6d_6f39_e94e4efd9850["testTlsConnection()"]
  938821ed_7909_bb31_9c78_1d4536ee982b["PkiTestingTlsTest"]
  a8eac5c5_344b_7e6d_6f39_e94e4efd9850 -->|defined in| 938821ed_7909_bb31_9c78_1d4536ee982b
  c65da3b1_05e4_27d2_a895_d5ef7ed855e8["connectWithClassicalAlgorithms()"]
  c65da3b1_05e4_27d2_a895_d5ef7ed855e8 -->|calls| a8eac5c5_344b_7e6d_6f39_e94e4efd9850
  cea9e376_01a4_af2e_0ca6_46efb41fb600["connectWithEd25519()"]
  cea9e376_01a4_af2e_0ca6_46efb41fb600 -->|calls| a8eac5c5_344b_7e6d_6f39_e94e4efd9850
  eed95e4e_189c_4491_cee2_0794e8520686["connectWithX25519MLKEM768()"]
  eed95e4e_189c_4491_cee2_0794e8520686 -->|calls| a8eac5c5_344b_7e6d_6f39_e94e4efd9850
  d960b596_11c1_9f7a_3c78_b975a04730e6["x25519MLKEM768Interoperability()"]
  d960b596_11c1_9f7a_3c78_b975a04730e6 -->|calls| a8eac5c5_344b_7e6d_6f39_e94e4efd9850
  style a8eac5c5_344b_7e6d_6f39_e94e4efd9850 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

handler/src/test/java/io/netty/handler/ssl/PkiTestingTlsTest.java lines 244–335

    private void testTlsConnection(SslContext serverContext, SslContext clientContext, String[] groups)
            throws InterruptedException {
        MultiThreadIoEventLoopGroup group = new MultiThreadIoEventLoopGroup(1, LocalIoHandler.newFactory());
        LocalAddress serverAddress = new LocalAddress(getClass());

        Channel serverChannel = null;
        Channel clientChannel = null;
        try {
            serverChannel = new ServerBootstrap()
                    .channel(LocalServerChannel.class)
                    .childHandler(new ChannelInitializer<Channel>() {
                        @Override
                        protected void initChannel(Channel ch) throws Exception {
                            SslHandler handler = serverContext.newHandler(ch.alloc());
                            if (groups != null) {
                                SSLParameters parameters = handler.engine().getSSLParameters();
                                OpenSslParametersUtil.setNamesGroups(parameters, groups);
                                handler.engine().setSSLParameters(parameters);
                            }
                            ch.pipeline().addLast(handler);
                        }
                    })
                    .group(group)
                    .bind(serverAddress).sync().channel();

            Promise<SslHandshakeCompletionEvent> promise = group.next().newPromise();

            clientChannel = new Bootstrap()
                    .channel(LocalChannel.class)
                    .group(group)
                    .handler(new ChannelInitializer<Channel>() {
                        @Override
                        protected void initChannel(Channel ch) throws Exception {
                            SslHandler handler = clientContext.newHandler(ch.alloc(), "localhost", 0);
                            if (groups != null) {
                                SSLParameters parameters = handler.engine().getSSLParameters();
                                OpenSslParametersUtil.setNamesGroups(parameters, groups);
                                handler.engine().setSSLParameters(parameters);
                            }
                            ch.pipeline()
                                    .addLast(handler)
                                    .addLast(new ChannelInboundHandlerAdapter() {
                                        @Override
                                        public void userEventTriggered(ChannelHandlerContext ctx, Object evt)
                                                throws Exception {
                                            if (evt instanceof SslHandshakeCompletionEvent) {
                                                SslHandshakeCompletionEvent shce = (SslHandshakeCompletionEvent) evt;
                                                if (shce.isSuccess()) {
                                                    promise.setSuccess(shce);
                                                } else {
                                                    promise.setFailure(shce.cause());
                                                }
                                                return;
                                            }
                                            super.userEventTriggered(ctx, evt);
                                        }

                                        @Override
                                        public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
                                                throws Exception {
                                            if (!promise.tryFailure(cause)) {
                                                ctx.fireExceptionCaught(cause);
                                            }
                                        }
                                    });
                        }
                    })
                    .connect(serverAddress)
                    .sync()
                    .channel();

            promise.sync();
        } finally {
            if (clientChannel != null) {
                clientChannel.close();
            }
            if (serverChannel != null) {
                serverChannel.close();
            }
            if (clientChannel != null) {
                clientChannel.closeFuture().sync();

Domain

Subdomains

Frequently Asked Questions

What does testTlsConnection() do?
testTlsConnection() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/PkiTestingTlsTest.java.
Where is testTlsConnection() defined?
testTlsConnection() is defined in handler/src/test/java/io/netty/handler/ssl/PkiTestingTlsTest.java at line 244.
What calls testTlsConnection()?
testTlsConnection() is called by 4 function(s): connectWithClassicalAlgorithms, connectWithEd25519, connectWithX25519MLKEM768, x25519MLKEM768Interoperability.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free