diff --git a/handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslEngine.java b/handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslEngine.java index ad904af876..79149a9077 100644 --- a/handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslEngine.java +++ b/handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslEngine.java @@ -962,7 +962,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(