Always include initial handshake exception when throwing SslHandshakeException (#9008)

Motivation:

A callback may already have stored a initial handshake exception in ReferenceCountedOpenSslEngine so we should include it when throwing a SslHandshakeException to ensure the user has all the infos when debugging.

Modifications:

Include initial handshake exception

Result:

Include all erros when throwing the SslHandshakeException.
This commit is contained in:
Norman Maurer 2019-04-05 09:55:32 +02:00 committed by GitHub
parent ad928c19eb
commit 547a375737
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -966,7 +966,14 @@ public class ReferenceCountedOpenSslEngine extends SSLEngine implements Referenc
if (handshakeState == HandshakeState.FINISHED) {
return new SSLException(errorString);
}
return new SSLHandshakeException(errorString);
SSLHandshakeException exception = new SSLHandshakeException(errorString);
// If we have a handshakeException stored already we should include it as well to help the user debug things.
if (handshakeException != null) {
exception.initCause(handshakeException);
handshakeException = null;
}
return exception;
}
public final SSLEngineResult unwrap(