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
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 ByteToMessageDecoder
ByteToMessageDecoder.CumulatorNested classes/interfaces inherited from interface ChannelHandler
ChannelHandler.Sharable -
Field Summary
FieldsFields inherited from class SslClientHelloHandler
MAX_CLIENT_HELLO_LENGTHFields inherited from class ByteToMessageDecoder
COMPOSITE_CUMULATOR, MERGE_CUMULATOR -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractSniHandler(int maxClientHelloLength, long handshakeTimeoutMillis) protectedAbstractSniHandler(long handshakeTimeoutMillis) -
Method Summary
Modifier and TypeMethodDescriptionvoidCallsChannelHandlerContext.fireChannelActive()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidDo nothing by default, sub-classes may override this method.lookup(ChannelHandlerContext ctx, ByteBuf clientHello) Kicks off a lookup for the givenClientHelloand returns aFuturewhich in turn will notify theSslClientHelloHandler.onLookupComplete(ChannelHandlerContext, Future)on completion.lookup(ChannelHandlerContext ctx, 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, String hostname, Future<T> future) Called upon completion of thelookup(ChannelHandlerContext, String)Future.Methods inherited from class SslClientHelloHandler
bind, close, connect, decode, deregister, disconnect, flush, handlerRemoved0, read, writeMethods inherited from class ByteToMessageDecoder
actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggeredMethods inherited from class ChannelInboundHandlerAdapter
channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaughtMethods inherited from class ChannelHandlerAdapter
ensureNotSharable, isSharableMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ChannelHandler
handlerRemoved
-
Field Details
-
handshakeTimeoutMillis
protected final long handshakeTimeoutMillis
-
-
Constructor Details
-
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 Details
-
handlerAdded
Description copied from class:ChannelHandlerAdapterDo nothing by default, sub-classes may override this method.- Specified by:
handlerAddedin interfaceChannelHandler- Overrides:
handlerAddedin classChannelHandlerAdapter- Throws:
Exception
-
channelActive
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:
Exception
-
lookup
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_suitesinvalid input: '<'2..2^16-2>; CompressionMethod compression_methodsinvalid input: '<'1..2^8-1>; select (extensions_present) { case false: struct {}; case true: Extension extensionsinvalid input: '<'0..2^16-1>; }; } ClientHello;- Specified by:
lookupin classSslClientHelloHandler<T>- Throws:
Exception- See Also:
-
onLookupComplete
Description copied from class:SslClientHelloHandlerCalled upon completion of theSslClientHelloHandler.lookup(ChannelHandlerContext, ByteBuf)Future.- Specified by:
onLookupCompletein classSslClientHelloHandler<T>- Throws:
Exception- See Also:
-
lookup
Kicks off a lookup for the given SNI value and returns aFuturewhich in turn will notify theonLookupComplete(ChannelHandlerContext, String, Future)on completion.- Throws:
Exception- See Also:
-
onLookupComplete
protected abstract void onLookupComplete(ChannelHandlerContext ctx, String hostname, Future<T> future) throws Exception Called upon completion of thelookup(ChannelHandlerContext, String)Future.- Throws:
Exception- See Also:
-