Home / Class/ SocketSslSessionReuseTest Class — netty Architecture

SocketSslSessionReuseTest Class — netty Architecture

Architecture documentation for the SocketSslSessionReuseTest class in SocketSslSessionReuseTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  833479b7_a1b1_3c02_8b20_02d1937b1c41["SocketSslSessionReuseTest"]
  5db688ae_c289_64df_2763_37867a6d3ea4["SocketSslSessionReuseTest.java"]
  833479b7_a1b1_3c02_8b20_02d1937b1c41 -->|defined in| 5db688ae_c289_64df_2763_37867a6d3ea4
  96c4151e_bd2e_669f_9a30_7f84b42e5872["jdkOnly()"]
  833479b7_a1b1_3c02_8b20_02d1937b1c41 -->|method| 96c4151e_bd2e_669f_9a30_7f84b42e5872
  217a39c1_ae27_e8b5_b6a7_c3c22148600d["jdkAndOpenSSL()"]
  833479b7_a1b1_3c02_8b20_02d1937b1c41 -->|method| 217a39c1_ae27_e8b5_b6a7_c3c22148600d
  3dfa3b91_4810_54f7_0f98_7be1c3c2bd16["testSslSessionReuse()"]
  833479b7_a1b1_3c02_8b20_02d1937b1c41 -->|method| 3dfa3b91_4810_54f7_0f98_7be1c3c2bd16
  13e35bed_4bc6_10f5_7d5a_38c7f6a201a9["testSslSessionTrustManagerResumption()"]
  833479b7_a1b1_3c02_8b20_02d1937b1c41 -->|method| 13e35bed_4bc6_10f5_7d5a_38c7f6a201a9
  e08e7362_dcfa_4a06_449b_f3a03c694e30["rethrowHandlerExceptions()"]
  833479b7_a1b1_3c02_8b20_02d1937b1c41 -->|method| e08e7362_dcfa_4a06_449b_f3a03c694e30
  1fd40b44_9ff3_c6d7_f7b9_c4379dc00a6d["sessionIdSet()"]
  833479b7_a1b1_3c02_8b20_02d1937b1c41 -->|method| 1fd40b44_9ff3_c6d7_f7b9_c4379dc00a6d

Relationship Graph

Source Code

testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketSslSessionReuseTest.java lines 74–379

public class SocketSslSessionReuseTest extends AbstractSocketTest {

    private static final InternalLogger logger = InternalLoggerFactory.getInstance(SocketSslSessionReuseTest.class);

    private static final File CERT_FILE;
    private static final File KEY_FILE;

    static {
        try {
            X509Bundle cert = new CertificateBuilder()
                    .subject("cn=localhost")
                    .setIsCertificateAuthority(true)
                    .buildSelfSigned();
            CERT_FILE = cert.toTempCertChainPem();
            KEY_FILE = cert.toTempPrivateKeyPem();
        } catch (Exception e) {
            throw new ExceptionInInitializerError(e);
        }
    }

    public static Collection<Object[]> jdkOnly() throws Exception {
        return Collections.singleton(new Object[]{
                SslContextBuilder.forServer(CERT_FILE, KEY_FILE).sslProvider(SslProvider.JDK),
                SslContextBuilder.forClient().trustManager(CERT_FILE).sslProvider(SslProvider.JDK)
                        .endpointIdentificationAlgorithm(null)
        });
    }

    public static Collection<Object[]> jdkAndOpenSSL() throws Exception {
        return Arrays.asList(new Object[]{
                        SslContextBuilder.forServer(CERT_FILE, KEY_FILE).sslProvider(SslProvider.JDK),
                        SslContextBuilder.forClient().trustManager(CERT_FILE).sslProvider(SslProvider.JDK)
                                .endpointIdentificationAlgorithm(null)
                },
                new Object[]{
                        SslContextBuilder.forServer(CERT_FILE, KEY_FILE).sslProvider(SslProvider.OPENSSL),
                        SslContextBuilder.forClient().trustManager(CERT_FILE).sslProvider(SslProvider.OPENSSL)
                                .endpointIdentificationAlgorithm(null)
                });
    }

    @ParameterizedTest(name = "{index}: serverEngine = {0}, clientEngine = {1}")
    @MethodSource("jdkOnly")
    @Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
    public void testSslSessionReuse(
            final SslContextBuilder serverCtx, final SslContextBuilder clientCtx, TestInfo testInfo) throws Throwable {
        run(testInfo, new Runner<ServerBootstrap, Bootstrap>() {
            @Override
            public void run(ServerBootstrap serverBootstrap, Bootstrap bootstrap) throws Throwable {
                testSslSessionReuse(sb, cb, serverCtx.build(), clientCtx.build());
            }
        });
    }

    public void testSslSessionReuse(ServerBootstrap sb, Bootstrap cb,
                                    final SslContext serverCtx, final SslContext clientCtx) throws Throwable {
        final ReadAndDiscardHandler sh = new ReadAndDiscardHandler(true, true);
        final ReadAndDiscardHandler ch = new ReadAndDiscardHandler(false, true);
        final String[] protocols = { "TLSv1", "TLSv1.1", "TLSv1.2" };

        sb.childHandler(new ChannelInitializer<SocketChannel>() {
            @Override
            protected void initChannel(SocketChannel sch) throws Exception {
                SSLEngine engine = serverCtx.newEngine(sch.alloc());
                engine.setUseClientMode(false);
                engine.setEnabledProtocols(protocols);

                sch.pipeline().addLast(new SslHandler(engine));
                sch.pipeline().addLast(sh);
            }
        });
        final Channel sc = sb.bind().sync().channel();

        cb.handler(new ChannelInitializer<SocketChannel>() {
            @Override
            protected void initChannel(SocketChannel sch) throws Exception {
                InetSocketAddress serverAddr = (InetSocketAddress) sc.localAddress();
                SSLEngine engine = clientCtx.newEngine(sch.alloc(), serverAddr.getHostString(), serverAddr.getPort());
                engine.setUseClientMode(true);
                engine.setEnabledProtocols(protocols);

Frequently Asked Questions

What is the SocketSslSessionReuseTest class?
SocketSslSessionReuseTest is a class in the netty codebase, defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketSslSessionReuseTest.java.
Where is SocketSslSessionReuseTest defined?
SocketSslSessionReuseTest is defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketSslSessionReuseTest.java at line 74.

Analyze Your Own Codebase

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

Try Supermodel Free