Skip to content

Commit

Permalink
Fix OpenSslEngineTest.testMaxCertificateList for TLSv1.3 (#13855)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
normanmaurer committed Feb 19, 2024
1 parent 467322e commit 68b0989
Showing 1 changed file with 8 additions and 1 deletion.
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 68b0989

Please sign in to comment.