From c392339feb67be9191eae324edf7d04eb54c54bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kohlschu=CC=88tter?= Date: Sat, 23 Sep 2023 16:59:34 +0200 Subject: [PATCH] ssl: Unbreak tests on IBM Semeru 8 / IBMJSSEProvider2 It seems like all JSSE providers choose to throw their own exceptions at will. --- .../net/unix/ssl/SSLContextBuilderTest.java | 43 ++++++++----------- .../ssl/ValidatingX509TrustManagerTest.java | 19 +++++--- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/junixsocket-ssl/src/test/java/org/newsclub/net/unix/ssl/SSLContextBuilderTest.java b/junixsocket-ssl/src/test/java/org/newsclub/net/unix/ssl/SSLContextBuilderTest.java index ae9e86d07..226fa7792 100644 --- a/junixsocket-ssl/src/test/java/org/newsclub/net/unix/ssl/SSLContextBuilderTest.java +++ b/junixsocket-ssl/src/test/java/org/newsclub/net/unix/ssl/SSLContextBuilderTest.java @@ -51,6 +51,7 @@ import javax.net.ssl.SSLContext; import javax.net.ssl.SSLEngine; +import javax.net.ssl.SSLException; import javax.net.ssl.SSLHandshakeException; import javax.net.ssl.SSLProtocolException; import javax.net.ssl.SSLServerSocket; @@ -177,17 +178,15 @@ public void testClientAuthRequiredButClientIsNotSendingAKey(TestSSLConfiguration // both client and server should throw an SSLHandshakeException or SocketException assertInstanceOf(serverException.get(), SSLHandshakeException.class, SocketException.class, // - SSLProtocolException.class, BOUNCYCASTLE_TLS_EXCEPTION /* - * org.bouncycastle.tls. - * TlsFatalAlert - */ // Bouncycastle + SSLProtocolException.class, // + BOUNCYCASTLE_TLS_EXCEPTION, // org.bouncycastle.tls.TlsFatalAlert + SSLException.class // IBMJSSEProvider2 ); assertInstanceOf(clientException.get(), null, SSLHandshakeException.class, SocketException.class, // - SSLProtocolException.class, BOUNCYCASTLE_TLS_EXCEPTION/* - * org.bouncycastle.tls. - * TlsFatalAlert - */ // Bouncycastle + SSLProtocolException.class, // + BOUNCYCASTLE_TLS_EXCEPTION, // org.bouncycastle.tls.TlsFatalAlert + SSLException.class // IBMJSSEProvider2 ); }); } finally { @@ -227,17 +226,15 @@ public void testClientAuthRequiredButClientKeyIsNotTrusted(TestSSLConfiguration // both client and server should throw an SSLHandshakeException or SocketException assertInstanceOf(serverException.get(), SSLHandshakeException.class, SocketException.class, // - SSLProtocolException.class, BOUNCYCASTLE_TLS_EXCEPTION /* - * org.bouncycastle.tls. - * TlsFatalAlert - */ // Bouncycastle + SSLProtocolException.class, // + BOUNCYCASTLE_TLS_EXCEPTION, // org.bouncycastle.tls.TlsFatalAlert + SSLException.class // IBMJSSEProvider2 ); assertInstanceOf(clientException.get(), null, SSLHandshakeException.class, SocketException.class, // - SSLProtocolException.class, BOUNCYCASTLE_TLS_EXCEPTION /* - * org.bouncycastle.tls. - * TlsFatalAlert - */ // Bouncycastle + SSLProtocolException.class, // + BOUNCYCASTLE_TLS_EXCEPTION, // org.bouncycastle.tls.TlsFatalAlert + SSLException.class // IBMJSSEProvider2 ); }); } finally { @@ -272,17 +269,15 @@ public void testClientHasNoTrustStore(TestSSLConfiguration configuration) throws // both client and server should throw an SSLHandshakeException or SocketException assertInstanceOf(serverException.get(), SSLHandshakeException.class, SocketException.class, // - SSLProtocolException.class, BOUNCYCASTLE_TLS_EXCEPTION /* - * org.bouncycastle.tls. - * TlsFatalAlert - */ // Bouncycastle + SSLProtocolException.class, // + BOUNCYCASTLE_TLS_EXCEPTION, // org.bouncycastle.tls.TlsFatalAlert + SSLException.class // IBMJSSEProvider2 ); assertInstanceOf(clientException.get(), null, SSLHandshakeException.class, SocketException.class, // - SSLProtocolException.class, BOUNCYCASTLE_TLS_EXCEPTION /* - * org.bouncycastle.tls. - * TlsFatalAlert - */ // Bouncycastle + SSLProtocolException.class, // + BOUNCYCASTLE_TLS_EXCEPTION, // org.bouncycastle.tls.TlsFatalAlert + SSLException.class // IBMJSSEProvider2 ); }); } finally { diff --git a/junixsocket-ssl/src/test/java/org/newsclub/net/unix/ssl/ValidatingX509TrustManagerTest.java b/junixsocket-ssl/src/test/java/org/newsclub/net/unix/ssl/ValidatingX509TrustManagerTest.java index 389dc0f56..6cb06c119 100644 --- a/junixsocket-ssl/src/test/java/org/newsclub/net/unix/ssl/ValidatingX509TrustManagerTest.java +++ b/junixsocket-ssl/src/test/java/org/newsclub/net/unix/ssl/ValidatingX509TrustManagerTest.java @@ -40,6 +40,7 @@ import javax.net.ssl.SNIHostName; import javax.net.ssl.SNIServerName; +import javax.net.ssl.SSLException; import javax.net.ssl.SSLHandshakeException; import javax.net.ssl.SSLProtocolException; import javax.net.ssl.SSLSocket; @@ -96,10 +97,12 @@ public void testInspectTrustedCertificateExpired(TestSSLConfiguration configurat }); assertInstanceOf(serverException.get(), SocketException.class, SSLHandshakeException.class, // - SSLProtocolException.class, BOUNCYCASTLE_TLS_EXCEPTION // Bouncycastle + SSLProtocolException.class, BOUNCYCASTLE_TLS_EXCEPTION, // Bouncycastle, + SSLException.class // IBMJSSEProvider2 ); assertInstanceOf(clientException.get(), SocketException.class, SSLHandshakeException.class, // - SSLProtocolException.class, BOUNCYCASTLE_TLS_EXCEPTION // Bouncycastle + SSLProtocolException.class, BOUNCYCASTLE_TLS_EXCEPTION, // Bouncycastle, + SSLException.class // IBMJSSEProvider2 ); } finally { Files.deleteIfExists(addr.getFile().toPath()); @@ -198,10 +201,12 @@ public void testInspectTrustedCertificateExpiredNested(TestSSLConfiguration conf }); assertInstanceOf(serverException.get(), SocketException.class, SSLHandshakeException.class, // - SSLProtocolException.class, BOUNCYCASTLE_TLS_EXCEPTION // Bouncycastle + SSLProtocolException.class, BOUNCYCASTLE_TLS_EXCEPTION, // Bouncycastle, + SSLException.class // IBMJSSEProvider2 ); assertInstanceOf(clientException.get(), SocketException.class, SSLHandshakeException.class, // - SSLProtocolException.class, BOUNCYCASTLE_TLS_EXCEPTION // Bouncycastle + SSLProtocolException.class, BOUNCYCASTLE_TLS_EXCEPTION, // Bouncycastle, + SSLException.class // IBMJSSEProvider2 ); } finally { Files.deleteIfExists(addr.getFile().toPath()); @@ -367,10 +372,12 @@ public void testInspectTrustedClientCertificateExpired(TestSSLConfiguration conf }); assertInstanceOf(serverException.get(), SocketException.class, SSLHandshakeException.class, // - SSLProtocolException.class, BOUNCYCASTLE_TLS_EXCEPTION // Bouncycastle + SSLProtocolException.class, BOUNCYCASTLE_TLS_EXCEPTION, // Bouncycastle, + SSLException.class // IBMJSSEProvider2 ); assertInstanceOf(clientException.get(), SocketException.class, SSLHandshakeException.class, // - SSLProtocolException.class, BOUNCYCASTLE_TLS_EXCEPTION // Bouncycastle + SSLProtocolException.class, BOUNCYCASTLE_TLS_EXCEPTION, // Bouncycastle, + SSLException.class // IBMJSSEProvider2 ); } finally { Files.deleteIfExists(addr.getFile().toPath());