NETTY-428 SslHandler does not trigger an exceptionCaught event for some handshake failure cases.
* Made sure SslHandler.handshake() and SslHandler.close() trigger an exceptionCaught event when failed
This commit is contained in:
parent
21269fa073
commit
88d84c537c
@ -51,7 +51,7 @@ public class SecureChatClientPipelineFactory implements
|
||||
|
||||
SSLEngine engine =
|
||||
SecureChatSslContextFactory.getClientContext().createSSLEngine();
|
||||
engine.setUseClientMode(true);
|
||||
//engine.setUseClientMode(true);
|
||||
|
||||
pipeline.addLast("ssl", new SslHandler(engine));
|
||||
|
||||
|
@ -329,6 +329,8 @@ public class SslHandler extends FrameDecoder
|
||||
ChannelHandlerContext ctx = this.ctx;
|
||||
Channel channel = ctx.getChannel();
|
||||
ChannelFuture handshakeFuture;
|
||||
Exception exception = null;
|
||||
|
||||
synchronized (handshakeLock) {
|
||||
if (handshaking) {
|
||||
return this.handshakeFuture;
|
||||
@ -340,15 +342,22 @@ public class SslHandler extends FrameDecoder
|
||||
handshakeFuture = this.handshakeFuture = future(channel);
|
||||
} catch (Exception e) {
|
||||
handshakeFuture = this.handshakeFuture = failedFuture(channel, e);
|
||||
exception = e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (exception == null) { // Began handshake successfully.
|
||||
try {
|
||||
wrapNonAppData(ctx, channel);
|
||||
} catch (SSLException e) {
|
||||
fireExceptionCaught(ctx, e);
|
||||
handshakeFuture.setFailure(e);
|
||||
}
|
||||
} else { // Failed to initiate handshake.
|
||||
fireExceptionCaught(ctx, exception);
|
||||
}
|
||||
|
||||
return handshakeFuture;
|
||||
}
|
||||
|
||||
@ -363,6 +372,7 @@ public class SslHandler extends FrameDecoder
|
||||
engine.closeOutbound();
|
||||
return wrapNonAppData(ctx, channel);
|
||||
} catch (SSLException e) {
|
||||
fireExceptionCaught(ctx, e);
|
||||
return failedFuture(channel, e);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user