Home / Function/ testHandshake() — netty Function Reference

testHandshake() — netty Function Reference

Architecture documentation for the testHandshake() function in CipherSuiteCanaryTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  87f631b4_7f6e_b2c2_60d6_d3e0f574ee13["testHandshake()"]
  ab6381a6_f969_6ff9_7dc9_1144730032e7["CipherSuiteCanaryTest"]
  87f631b4_7f6e_b2c2_60d6_d3e0f574ee13 -->|defined in| ab6381a6_f969_6ff9_7dc9_1144730032e7
  03e9881c_2c51_2a77_b993_13603c2ccfda["assumeCipherAvailable()"]
  87f631b4_7f6e_b2c2_60d6_d3e0f574ee13 -->|calls| 03e9881c_2c51_2a77_b993_13603c2ccfda
  style 87f631b4_7f6e_b2c2_60d6_d3e0f574ee13 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

handler/src/test/java/io/netty/handler/ssl/CipherSuiteCanaryTest.java lines 118–247

    @ParameterizedTest(
            name = "{index}: serverSslProvider = {0}, clientSslProvider = {1}, rfcCipherName = {2}, delegate = {3}")
    @MethodSource("parameters")
    public void testHandshake(SslProvider serverSslProvider, SslProvider clientSslProvider,
                              String rfcCipherName, boolean delegate) throws Exception {
        // Check if the cipher is supported at all which may not be the case for various JDK versions and OpenSSL API
        // implementations.
        assumeCipherAvailable(serverSslProvider, rfcCipherName);
        assumeCipherAvailable(clientSslProvider, rfcCipherName);

        List<String> ciphers = Collections.singletonList(rfcCipherName);

        PrivateKey privateKey = CERT.getKeyPair().getPrivate();
        X509Certificate[] certChain = CERT.getCertificatePath();
        final SslContext sslServerContext = SslContextBuilder.forServer(privateKey, certChain)
                .sslProvider(serverSslProvider)
                .ciphers(ciphers)
                // As this is not a TLSv1.3 cipher we should ensure we talk something else.
                .protocols(SslProtocols.TLS_v1_2)
                .build();

        final ExecutorService executorService = delegate ? Executors.newCachedThreadPool() : null;

        try {
            final SslContext sslClientContext = SslContextBuilder.forClient()
                    .sslProvider(clientSslProvider)
                    .ciphers(ciphers)
                    // As this is not a TLSv1.3 cipher we should ensure we talk something else.
                    .protocols(SslProtocols.TLS_v1_2)
                    .trustManager(InsecureTrustManagerFactory.INSTANCE)
                    .build();

            try {
                final Promise<Object> serverPromise = GROUP.next().newPromise();
                final Promise<Object> clientPromise = GROUP.next().newPromise();

                ChannelHandler serverHandler = new ChannelInitializer<Channel>() {
                    @Override
                    protected void initChannel(Channel ch) throws Exception {
                        ChannelPipeline pipeline = ch.pipeline();
                        pipeline.addLast(newSslHandler(sslServerContext, ch.alloc(), executorService));

                        pipeline.addLast(new SimpleChannelInboundHandler<Object>() {
                            @Override
                            public void channelInactive(ChannelHandlerContext ctx) throws Exception {
                                serverPromise.cancel(true);
                                ctx.fireChannelInactive();
                            }

                            @Override
                            public void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
                                if (serverPromise.trySuccess(null)) {
                                    ctx.writeAndFlush(Unpooled.wrappedBuffer(new byte[] {'P', 'O', 'N', 'G'}));
                                }
                                ctx.close();
                            }

                            @Override
                            public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
                                if (!serverPromise.tryFailure(cause)) {
                                    ctx.fireExceptionCaught(cause);
                                }
                            }
                        });
                    }
                };

                LocalAddress address = new LocalAddress("test-" + serverSslProvider
                        + '-' + clientSslProvider + '-' + rfcCipherName);

                Channel server = server(address, serverHandler);
                try {
                    ChannelHandler clientHandler = new ChannelInitializer<Channel>() {
                        @Override
                        protected void initChannel(Channel ch) throws Exception {
                            ChannelPipeline pipeline = ch.pipeline();
                            pipeline.addLast(newSslHandler(sslClientContext, ch.alloc(), executorService));

                            pipeline.addLast(new SimpleChannelInboundHandler<Object>() {
                                @Override
                                public void channelInactive(ChannelHandlerContext ctx) throws Exception {

Domain

Subdomains

Frequently Asked Questions

What does testHandshake() do?
testHandshake() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/CipherSuiteCanaryTest.java.
Where is testHandshake() defined?
testHandshake() is defined in handler/src/test/java/io/netty/handler/ssl/CipherSuiteCanaryTest.java at line 118.
What does testHandshake() call?
testHandshake() calls 1 function(s): assumeCipherAvailable.

Analyze Your Own Codebase

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

Try Supermodel Free