Skip to content

Commit

Permalink
ssl: Unbreak tests on IBM Semeru 8 / IBMJSSEProvider2
Browse files Browse the repository at this point in the history
It seems like all JSSE providers choose to throw their own exceptions at
will.
  • Loading branch information
kohlschuetter committed Sep 23, 2023
1 parent a70cc29 commit c392339
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit c392339

Please sign in to comment.