SSLEngineTest issue introduced by d8e6fbb9c3

Motivation:
d8e6fbb9c3 attempted to account for the JDK not throwing the expected SSLHandshakeException by allowing a SSLException to also pass the test. However in some situations the SSLException will not be the top level exception and the Throwable must be unwrapped to see if the root cause is an SSLException.

Modifications:
- Unwrap exceptions thrown by the JDK's SSLEngine to check for SSLException.

Result:
SSLEngineTest (and derived classes) are more reliable.
This commit is contained in:
Scott Mitchell 2017-02-20 10:14:38 -08:00
parent 576baf8e6c
commit 2dffc2f9fb
3 changed files with 13 additions and 2 deletions

View File

@ -88,6 +88,6 @@ public class JdkOpenSslEngineInteroptTest extends SSLEngineTest {
@Override
protected boolean mySetupMutualAuthServerIsValidClientException(Throwable cause) {
// TODO(scott): work around for a JDK issue. The exception should be SSLHandshakeException.
return super.mySetupMutualAuthServerIsValidClientException(cause) || cause instanceof SSLException;
return super.mySetupMutualAuthServerIsValidClientException(cause) || causedBySSLException(cause);
}
}

View File

@ -92,6 +92,6 @@ public class OpenSslJdkSslEngineInteroptTest extends SSLEngineTest {
@Override
protected boolean mySetupMutualAuthServerIsValidServerException(Throwable cause) {
// TODO(scott): work around for a JDK issue. The exception should be SSLHandshakeException.
return super.mySetupMutualAuthServerIsValidServerException(cause) || cause instanceof SSLException;
return super.mySetupMutualAuthServerIsValidServerException(cause) || causedBySSLException(cause);
}
}

View File

@ -593,6 +593,17 @@ public abstract class SSLEngineTest {
mySetupMutualAuthServerIsValidServerException(serverException));
}
protected static boolean causedBySSLException(Throwable cause) {
Throwable next = cause;
do {
if (next instanceof SSLException) {
return true;
}
next = next.getCause();
} while (next != null);
return false;
}
protected boolean mySetupMutualAuthServerIsValidServerException(Throwable cause) {
return mySetupMutualAuthServerIsValidException(cause);
}