From 68b09894f36e790e29859f6e12f1453255663fae Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Mon, 19 Feb 2024 15:30:08 +0100 Subject: [PATCH] Fix OpenSslEngineTest.testMaxCertificateList for TLSv1.3 (#13855) Motivation: When using TLSv1.3 we might only throw the exception once the handshake is considered done Modifications: Fix test to assert the correct thing Result: All tests pass on all platforms with all tcnative libs --- .../java/io/netty/handler/ssl/OpenSslEngineTest.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/handler/src/test/java/io/netty/handler/ssl/OpenSslEngineTest.java b/handler/src/test/java/io/netty/handler/ssl/OpenSslEngineTest.java index ece51cb72fe..dec5085c3dd 100644 --- a/handler/src/test/java/io/netty/handler/ssl/OpenSslEngineTest.java +++ b/handler/src/test/java/io/netty/handler/ssl/OpenSslEngineTest.java @@ -67,6 +67,7 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertSame; @@ -1634,12 +1635,18 @@ public void testMaxCertificateList(final SSLEngineTestParam param) throws Except final SSLEngine server = wrapEngine(serverSslCtx.newEngine(UnpooledByteBufAllocator.DEFAULT)); try { - assertThrows(SSLHandshakeException.class, new Executable() { + SSLException e = assertThrows(SSLException.class, new Executable() { @Override public void execute() throws Throwable { handshake(param.type(), param.delegate(), client, server); } }); + // In the case of TLS_v1_3 we might only generate the exception once the actual handshake is considered + // done. If other protocols this should be generasted during the handshake itself and so be of type + // SSLHandshakeException. + if (!SslProtocols.TLS_v1_3.equals(client.getSession().getProtocol())) { + assertInstanceOf(SSLHandshakeException.class, e); + } } finally { cleanupClientSslEngine(client); cleanupServerSslEngine(server);