Home / Function/ connectUsingHttpAndValidateCertificateUsingOcspTest() — netty Function Reference

connectUsingHttpAndValidateCertificateUsingOcspTest() — netty Function Reference

Architecture documentation for the connectUsingHttpAndValidateCertificateUsingOcspTest() function in OcspServerCertificateValidatorTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  9e74b6c7_52ae_dbaf_7567_2cded7385e15["connectUsingHttpAndValidateCertificateUsingOcspTest()"]
  6e4ab173_5fa8_49eb_3976_e927c5435ba9["OcspServerCertificateValidatorTest"]
  9e74b6c7_52ae_dbaf_7567_2cded7385e15 -->|defined in| 6e4ab173_5fa8_49eb_3976_e927c5435ba9
  style 9e74b6c7_52ae_dbaf_7567_2cded7385e15 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

handler-ssl-ocsp/src/test/java/io/netty/handler/ssl/ocsp/OcspServerCertificateValidatorTest.java lines 43–96

    @Test
    void connectUsingHttpAndValidateCertificateUsingOcspTest() throws Exception {
        final AtomicBoolean ocspStatus = new AtomicBoolean();
        EventLoopGroup eventLoopGroup = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());

        try {
            final CountDownLatch latch = new CountDownLatch(1);
            final SslContext sslContext = SslContextBuilder.forClient()
                    .trustManager(InsecureTrustManagerFactory.INSTANCE)
                    .build();

            Bootstrap bootstrap = new Bootstrap()
                    .group(eventLoopGroup)
                    .channel(NioSocketChannel.class)
                    .option(ChannelOption.TCP_NODELAY, true)
                    .handler(new ChannelInitializer<SocketChannel>() {
                        @Override
                        protected void initChannel(SocketChannel ch) {
                            ChannelPipeline pipeline = ch.pipeline();
                            pipeline.addLast(sslContext.newHandler(ch.alloc(), "netty.io", 443));
                            pipeline.addLast(new OcspServerCertificateValidator(false, createDefaultTransport()));
                            pipeline.addLast(new SimpleChannelInboundHandler<Object>() {
                                @Override
                                protected void channelRead0(ChannelHandlerContext ctx, Object msg) {
                                    // NOOP
                                }

                                @Override
                                public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
                                    if (evt instanceof OcspValidationEvent) {
                                        OcspValidationEvent event = (OcspValidationEvent) evt;

                                        ocspStatus.set(event.response().status() == OcspResponse.Status.VALID);
                                        ctx.channel().close();
                                        latch.countDown();
                                    }
                                }
                            });
                        }
                    });

            ChannelFuture channelFuture = bootstrap.connect("netty.io", 443);
            channelFuture.sync();

            // Wait for maximum of 1 minute for Ocsp validation to happen
            latch.await(1, TimeUnit.MINUTES);
            assertTrue(ocspStatus.get());

            // Wait for Channel to be closed
            channelFuture.channel().closeFuture().sync();
        } finally {
            eventLoopGroup.shutdownGracefully();
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does connectUsingHttpAndValidateCertificateUsingOcspTest() do?
connectUsingHttpAndValidateCertificateUsingOcspTest() is a function in the netty codebase, defined in handler-ssl-ocsp/src/test/java/io/netty/handler/ssl/ocsp/OcspServerCertificateValidatorTest.java.
Where is connectUsingHttpAndValidateCertificateUsingOcspTest() defined?
connectUsingHttpAndValidateCertificateUsingOcspTest() is defined in handler-ssl-ocsp/src/test/java/io/netty/handler/ssl/ocsp/OcspServerCertificateValidatorTest.java at line 43.

Analyze Your Own Codebase

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

Try Supermodel Free