ApplicationProtocolNegotiationHandler failure behavior

Motivation:
Child classes of ApplicationProtocolNegotiationHandler may want to override the behavior when a handshake failure is detected.

Modifications:
- Provide a method which can be overriden when a handshake failure is detected.

Result:
Child classes can override ApplicationProtocolNegotiationHandler handshake failure behavior.
This commit is contained in:
Scott Mitchell 2015-11-04 11:20:12 -08:00
parent 6e108cb96a
commit 21e27da410

View File

@ -99,8 +99,7 @@ public abstract class ApplicationProtocolNegotiationHandler extends ChannelInbou
String protocol = sslHandler.applicationProtocol();
configurePipeline(ctx, protocol != null? protocol : fallbackProtocol);
} else {
logger.warn("{} TLS handshake failed:", ctx.channel(), handshakeEvent.cause());
ctx.close();
handshakeFailure(ctx, handshakeEvent.cause());
}
}
@ -117,6 +116,14 @@ public abstract class ApplicationProtocolNegotiationHandler extends ChannelInbou
*/
protected abstract void configurePipeline(ChannelHandlerContext ctx, String protocol) throws Exception;
/**
* Invoked on failed initial SSL/TLS handshake.
*/
protected void handshakeFailure(ChannelHandlerContext ctx, Throwable cause) throws Exception {
logger.warn("{} TLS handshake failed:", ctx.channel(), cause);
ctx.close();
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
logger.warn("{} Failed to select the application-level protocol:", ctx.channel(), cause);