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.SharableModifier and TypeInterfaceDescriptionstatic @interfaceIndicates that the same instance of the annotatedChannelHandlercan be added to one or moreChannelPipelines multiple times without a race condition. -
Field Summary
FieldsFields inherited from class SslClientHelloHandler
MAX_CLIENT_HELLO_LENGTHModifier and TypeFieldDescriptionstatic final intThe maximum length of client hello message as defined by RFC5246.Fields inherited from class ByteToMessageDecoder
COMPOSITE_CUMULATOR, MERGE_CUMULATORModifier and TypeFieldDescriptionstatic final ByteToMessageDecoder.CumulatorCumulateByteBufs by add them to aCompositeByteBufand so do no memory copy whenever possible.static final ByteToMessageDecoder.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, writeModifier and TypeMethodDescriptionvoidbind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) Called once a bind operation is made.voidclose(ChannelHandlerContext ctx, ChannelPromise promise) Called once a close operation is made.voidconnect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) Called once a connect operation is made.protected voiddecode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) Decode the from oneByteBufto an other.voidderegister(ChannelHandlerContext ctx, ChannelPromise promise) Called once a deregister operation is made from the current registeredEventLoop.voiddisconnect(ChannelHandlerContext ctx, ChannelPromise promise) Called once a disconnect operation is made.voidCalled once a flush operation is made.protected voidGets called after theByteToMessageDecoderwas removed from the actual context and it doesn't handle events anymore.voidInterceptsChannelHandlerContext.read().voidwrite(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) Called once a write operation is made.Methods inherited from class ByteToMessageDecoder
actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggeredModifier and TypeMethodDescriptionprotected intReturns the actual number of readable bytes in the internal cumulative buffer of this decoder.protected voidcallDecode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) Called once data should be decoded from the givenByteBuf.voidCallsChannelHandlerContext.fireChannelInactive()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidchannelRead(ChannelHandlerContext ctx, Object input) CallsChannelHandlerContext.fireChannelRead(Object)to forward to the nextChannelInboundHandlerin theChannelPipeline.voidCallsChannelHandlerContext.fireChannelReadComplete()to forward to the nextChannelInboundHandlerin theChannelPipeline.protected voiddecodeLast(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) Is called one last time when theChannelHandlerContextgoes in-active.protected final voidfinal voidDo nothing by default, sub-classes may override this method.protected ByteBufReturns the internal cumulative buffer of this decoder.booleanIftruethen only one message is decoded on eachByteToMessageDecoder.channelRead(ChannelHandlerContext, Object)call.voidsetCumulator(ByteToMessageDecoder.Cumulator cumulator) Set theByteToMessageDecoder.Cumulatorto use for cumulate the receivedByteBufs.voidsetDiscardAfterReads(int discardAfterReads) Set the number of reads after whichByteBuf.discardSomeReadBytes()are called and so free up memory.voidsetSingleDecode(boolean singleDecode) If set then only one message is decoded on eachByteToMessageDecoder.channelRead(ChannelHandlerContext, Object)call.voiduserEventTriggered(ChannelHandlerContext ctx, Object evt) CallsChannelHandlerContext.fireUserEventTriggered(Object)to forward to the nextChannelInboundHandlerin theChannelPipeline.Methods inherited from class ChannelInboundHandlerAdapter
channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaughtModifier and TypeMethodDescriptionvoidCallsChannelHandlerContext.fireChannelRegistered()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidCallsChannelHandlerContext.fireChannelUnregistered()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidCallsChannelHandlerContext.fireChannelWritabilityChanged()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidexceptionCaught(ChannelHandlerContext ctx, Throwable cause) CallsChannelHandlerContext.fireExceptionCaught(Throwable)to forward to the nextChannelHandlerin theChannelPipeline.Methods inherited from class ChannelHandlerAdapter
ensureNotSharable, isSharableModifier and TypeMethodDescriptionprotected voidbooleanReturntrueif the implementation isChannelHandler.Sharableand so can be added to differentChannelPipelines.
-
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:
maxClientHelloLength- the maximum length of the client hello message.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:
-