Package io.netty.handler.ssl
Class AbstractSniHandler<T>
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.handler.codec.ByteToMessageDecoder
-
- io.netty.handler.ssl.SslClientHelloHandler<T>
-
- io.netty.handler.ssl.AbstractSniHandler<T>
-
- All Implemented Interfaces:
ChannelHandler,ChannelInboundHandler,ChannelOutboundHandler
- Direct Known Subclasses:
SniHandler
public abstract class AbstractSniHandler<T> extends SslClientHelloHandler<T>
Enables SNI (Server Name Indication) extension for server side SSL. For clients support SNI, the server could have multiple host name bound on a single IP. The client will send host name in the handshake data so server could decide which certificate to choose for the host name.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.netty.handler.codec.ByteToMessageDecoder
ByteToMessageDecoder.Cumulator
-
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Field Summary
Fields Modifier and Type Field Description protected longhandshakeTimeoutMillis-
Fields inherited from class io.netty.handler.ssl.SslClientHelloHandler
MAX_CLIENT_HELLO_LENGTH
-
Fields inherited from class io.netty.handler.codec.ByteToMessageDecoder
COMPOSITE_CUMULATOR, MERGE_CUMULATOR
-
-
Constructor Summary
Constructors Modifier Constructor Description AbstractSniHandler()protectedAbstractSniHandler(int maxClientHelloLength, long handshakeTimeoutMillis)protectedAbstractSniHandler(long handshakeTimeoutMillis)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidchannelActive(ChannelHandlerContext ctx)CallsChannelHandlerContext.fireChannelActive()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidhandlerAdded(ChannelHandlerContext ctx)Do nothing by default, sub-classes may override this method.protected Future<T>lookup(ChannelHandlerContext ctx, ByteBuf clientHello)Kicks off a lookup for the givenClientHelloand returns aFuturewhich in turn will notify theSslClientHelloHandler.onLookupComplete(ChannelHandlerContext, Future)on completion.protected abstract Future<T>lookup(ChannelHandlerContext ctx, java.lang.String hostname)Kicks off a lookup for the given SNI value and returns aFuturewhich in turn will notify theonLookupComplete(ChannelHandlerContext, String, Future)on completion.protected voidonLookupComplete(ChannelHandlerContext ctx, Future<T> future)Called upon completion of theSslClientHelloHandler.lookup(ChannelHandlerContext, ByteBuf)Future.protected abstract voidonLookupComplete(ChannelHandlerContext ctx, java.lang.String hostname, Future<T> future)Called upon completion of thelookup(ChannelHandlerContext, String)Future.-
Methods inherited from class io.netty.handler.ssl.SslClientHelloHandler
bind, close, connect, decode, deregister, disconnect, flush, handlerRemoved0, read, write
-
Methods inherited from class io.netty.handler.codec.ByteToMessageDecoder
actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggered
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, isSharable
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.channel.ChannelHandler
handlerRemoved
-
-
-
-
Constructor Detail
-
AbstractSniHandler
protected AbstractSniHandler(long handshakeTimeoutMillis)
- Parameters:
handshakeTimeoutMillis- the handshake timeout in milliseconds
-
AbstractSniHandler
protected AbstractSniHandler(int maxClientHelloLength, long handshakeTimeoutMillis)- Parameters:
handshakeTimeoutMillis- the handshake timeout in milliseconds
-
AbstractSniHandler
public AbstractSniHandler()
-
-
Method Detail
-
handlerAdded
public void handlerAdded(ChannelHandlerContext ctx) throws java.lang.Exception
Description copied from class:ChannelHandlerAdapterDo nothing by default, sub-classes may override this method.- Specified by:
handlerAddedin interfaceChannelHandler- Overrides:
handlerAddedin classChannelHandlerAdapter- Throws:
java.lang.Exception
-
channelActive
public void channelActive(ChannelHandlerContext ctx) throws java.lang.Exception
Description copied from class:ChannelInboundHandlerAdapterCallsChannelHandlerContext.fireChannelActive()to forward to the nextChannelInboundHandlerin theChannelPipeline. Sub-classes may override this method to change behavior.- Specified by:
channelActivein interfaceChannelInboundHandler- Overrides:
channelActivein classChannelInboundHandlerAdapter- Throws:
java.lang.Exception
-
lookup
protected Future<T> lookup(ChannelHandlerContext ctx, ByteBuf clientHello) throws java.lang.Exception
Description copied from class:SslClientHelloHandlerKicks off a lookup for the givenClientHelloand returns aFuturewhich in turn will notify theSslClientHelloHandler.onLookupComplete(ChannelHandlerContext, Future)on completion. See https://tools.ietf.org/html/rfc5246#section-7.4.1.2struct { ProtocolVersion client_version; Random random; SessionID session_id; CipherSuite cipher_suites<2..2^16-2>; CompressionMethod compression_methods<1..2^8-1>; select (extensions_present) { case false: struct {}; case true: Extension extensions<0..2^16-1>; }; } ClientHello;- Specified by:
lookupin classSslClientHelloHandler<T>- Throws:
java.lang.Exception- See Also:
SslClientHelloHandler.onLookupComplete(ChannelHandlerContext, Future)
-
onLookupComplete
protected void onLookupComplete(ChannelHandlerContext ctx, Future<T> future) throws java.lang.Exception
Description copied from class:SslClientHelloHandlerCalled upon completion of theSslClientHelloHandler.lookup(ChannelHandlerContext, ByteBuf)Future.- Specified by:
onLookupCompletein classSslClientHelloHandler<T>- Throws:
java.lang.Exception- See Also:
SslClientHelloHandler.lookup(ChannelHandlerContext, ByteBuf)
-
lookup
protected abstract Future<T> lookup(ChannelHandlerContext ctx, java.lang.String hostname) throws java.lang.Exception
Kicks off a lookup for the given SNI value and returns aFuturewhich in turn will notify theonLookupComplete(ChannelHandlerContext, String, Future)on completion.- Throws:
java.lang.Exception- See Also:
onLookupComplete(ChannelHandlerContext, String, Future)
-
onLookupComplete
protected abstract void onLookupComplete(ChannelHandlerContext ctx, java.lang.String hostname, Future<T> future) throws java.lang.Exception
Called upon completion of thelookup(ChannelHandlerContext, String)Future.- Throws:
java.lang.Exception- See Also:
lookup(ChannelHandlerContext, String)
-
-