diff --git a/handler/src/main/java/io/netty/handler/ssl/SslHandler.java b/handler/src/main/java/io/netty/handler/ssl/SslHandler.java index 34720bf0cd..bd9abdde4b 100644 --- a/handler/src/main/java/io/netty/handler/ssl/SslHandler.java +++ b/handler/src/main/java/io/netty/handler/ssl/SslHandler.java @@ -796,9 +796,14 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH runDelegatedTasks(); break; case NEED_UNWRAP: - if (!inUnwrap) { - unwrapNonAppData(ctx); + if (inUnwrap) { + // If we asked for a wrap, the engine requested an unwrap, and we are in unwrap there is + // no use in trying to call wrap again because we have already attempted (or will after we + // return) to feed more data to the engine. + return; } + + unwrapNonAppData(ctx); break; case NEED_WRAP: break;