testCorrectAlert() — netty Function Reference
Architecture documentation for the testCorrectAlert() function in SslErrorTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD d2d37dde_694d_d20e_8291_0b7fcc6a37b3["testCorrectAlert()"] 82658c62_302c_0f55_56df_d775fd8678b9["SslErrorTest"] d2d37dde_694d_d20e_8291_0b7fcc6a37b3 -->|defined in| 82658c62_302c_0f55_56df_d775fd8678b9 42006e41_acae_efcb_412e_c28527d652de["ExceptionTrustManagerFactory()"] d2d37dde_694d_d20e_8291_0b7fcc6a37b3 -->|calls| 42006e41_acae_efcb_412e_c28527d652de 08d587d4_3997_80f5_c5e8_89d3963066cf["AlertValidationHandler()"] d2d37dde_694d_d20e_8291_0b7fcc6a37b3 -->|calls| 08d587d4_3997_80f5_c5e8_89d3963066cf 5fd671a5_e3f0_0904_b972_222bc3b5f444["exceptionCaught()"] d2d37dde_694d_d20e_8291_0b7fcc6a37b3 -->|calls| 5fd671a5_e3f0_0904_b972_222bc3b5f444 style d2d37dde_694d_d20e_8291_0b7fcc6a37b3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/ssl/SslErrorTest.java lines 111–202
@ParameterizedTest(
name = "{index}: serverProvider = {0}, clientProvider = {1}, exception = {2}, serverProduceError = {3}")
@MethodSource("data")
@Timeout(value = 30000, unit = TimeUnit.MILLISECONDS)
public void testCorrectAlert(SslProvider serverProvider, final SslProvider clientProvider,
final CertificateException exception, final boolean serverProduceError)
throws Exception {
// As this only works correctly at the moment when OpenSslEngine is used on the server-side there is
// no need to run it if there is no openssl is available at all.
OpenSsl.ensureAvailability();
SelfSignedCertificate ssc = CachedSelfSignedCertificate.getCachedCertificate();
SslContextBuilder sslServerCtxBuilder = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey())
.sslProvider(serverProvider)
.clientAuth(ClientAuth.REQUIRE);
SslContextBuilder sslClientCtxBuilder = SslContextBuilder.forClient()
.keyManager(new File(getClass().getResource("test.crt").getFile()),
new File(getClass().getResource("test_unencrypted.pem").getFile()))
.sslProvider(clientProvider);
if (serverProduceError) {
sslServerCtxBuilder.trustManager(new ExceptionTrustManagerFactory(exception));
sslClientCtxBuilder.trustManager(InsecureTrustManagerFactory.INSTANCE);
} else {
sslServerCtxBuilder.trustManager(InsecureTrustManagerFactory.INSTANCE);
sslClientCtxBuilder.trustManager(new ExceptionTrustManagerFactory(exception));
}
final SslContext sslServerCtx = sslServerCtxBuilder.build();
final SslContext sslClientCtx = sslClientCtxBuilder.build();
Channel serverChannel = null;
Channel clientChannel = null;
EventLoopGroup group = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());
final Promise<Void> promise = group.next().newPromise();
try {
serverChannel = new ServerBootstrap().group(group)
.channel(NioServerSocketChannel.class)
.handler(new LoggingHandler(LogLevel.INFO))
.childHandler(new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel ch) {
ch.pipeline().addLast(sslServerCtx.newHandler(ch.alloc()));
if (!serverProduceError) {
ch.pipeline().addLast(new AlertValidationHandler(clientProvider, serverProduceError,
exception, promise));
}
ch.pipeline().addLast(new ChannelInboundHandlerAdapter() {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
ctx.close();
}
});
}
}).bind(0).sync().channel();
clientChannel = new Bootstrap().group(group)
.channel(NioSocketChannel.class)
.handler(new ChannelInitializer<Channel>() {
@Override
protected void initChannel(Channel ch) {
ch.pipeline().addLast(sslClientCtx.newHandler(ch.alloc()));
if (serverProduceError) {
ch.pipeline().addLast(new AlertValidationHandler(clientProvider, serverProduceError,
exception, promise));
}
ch.pipeline().addLast(new ChannelInboundHandlerAdapter() {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
ctx.close();
}
});
}
}).connect(serverChannel.localAddress()).syncUninterruptibly().channel();
// Block until we received the correct exception
promise.syncUninterruptibly();
} finally {
if (clientChannel != null) {
Domain
Subdomains
Source
Frequently Asked Questions
What does testCorrectAlert() do?
testCorrectAlert() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/SslErrorTest.java.
Where is testCorrectAlert() defined?
testCorrectAlert() is defined in handler/src/test/java/io/netty/handler/ssl/SslErrorTest.java at line 111.
What does testCorrectAlert() call?
testCorrectAlert() calls 3 function(s): AlertValidationHandler, ExceptionTrustManagerFactory, exceptionCaught.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free