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 =
|
SSLEngine engine =
|
||||||
SecureChatSslContextFactory.getClientContext().createSSLEngine();
|
SecureChatSslContextFactory.getClientContext().createSSLEngine();
|
||||||
engine.setUseClientMode(true);
|
//engine.setUseClientMode(true);
|
||||||
|
|
||||||
pipeline.addLast("ssl", new SslHandler(engine));
|
pipeline.addLast("ssl", new SslHandler(engine));
|
||||||
|
|
||||||
|
@ -329,6 +329,8 @@ public class SslHandler extends FrameDecoder
|
|||||||
ChannelHandlerContext ctx = this.ctx;
|
ChannelHandlerContext ctx = this.ctx;
|
||||||
Channel channel = ctx.getChannel();
|
Channel channel = ctx.getChannel();
|
||||||
ChannelFuture handshakeFuture;
|
ChannelFuture handshakeFuture;
|
||||||
|
Exception exception = null;
|
||||||
|
|
||||||
synchronized (handshakeLock) {
|
synchronized (handshakeLock) {
|
||||||
if (handshaking) {
|
if (handshaking) {
|
||||||
return this.handshakeFuture;
|
return this.handshakeFuture;
|
||||||
@ -340,15 +342,22 @@ public class SslHandler extends FrameDecoder
|
|||||||
handshakeFuture = this.handshakeFuture = future(channel);
|
handshakeFuture = this.handshakeFuture = future(channel);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
handshakeFuture = this.handshakeFuture = failedFuture(channel, e);
|
handshakeFuture = this.handshakeFuture = failedFuture(channel, e);
|
||||||
|
exception = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (exception == null) { // Began handshake successfully.
|
||||||
wrapNonAppData(ctx, channel);
|
try {
|
||||||
} catch (SSLException e) {
|
wrapNonAppData(ctx, channel);
|
||||||
handshakeFuture.setFailure(e);
|
} catch (SSLException e) {
|
||||||
|
fireExceptionCaught(ctx, e);
|
||||||
|
handshakeFuture.setFailure(e);
|
||||||
|
}
|
||||||
|
} else { // Failed to initiate handshake.
|
||||||
|
fireExceptionCaught(ctx, exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
return handshakeFuture;
|
return handshakeFuture;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,6 +372,7 @@ public class SslHandler extends FrameDecoder
|
|||||||
engine.closeOutbound();
|
engine.closeOutbound();
|
||||||
return wrapNonAppData(ctx, channel);
|
return wrapNonAppData(ctx, channel);
|
||||||
} catch (SSLException e) {
|
} catch (SSLException e) {
|
||||||
|
fireExceptionCaught(ctx, e);
|
||||||
return failedFuture(channel, e);
|
return failedFuture(channel, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user