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
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
FieldsFields 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
ConstructorsModifierConstructorDescriptionprotected
AbstractSniHandler
(int maxClientHelloLength, long handshakeTimeoutMillis) protected
AbstractSniHandler
(long handshakeTimeoutMillis) -
Method Summary
Modifier and TypeMethodDescriptionvoid
CallsChannelHandlerContext.fireChannelActive()
to forward to the nextChannelInboundHandler
in theChannelPipeline
.private void
private static String
private static void
fireSniCompletionEvent
(ChannelHandlerContext ctx, String hostname, Future<?> future) void
Do nothing by default, sub-classes may override this method.lookup
(ChannelHandlerContext ctx, ByteBuf clientHello) Kicks off a lookup for the givenClientHello
and returns aFuture
which 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 aFuture
which in turn will notify theonLookupComplete(ChannelHandlerContext, String, Future)
on completion.protected void
onLookupComplete
(ChannelHandlerContext ctx, Future<T> future) Called upon completion of theSslClientHelloHandler.lookup(ChannelHandlerContext, ByteBuf)
Future
.protected abstract void
onLookupComplete
(ChannelHandlerContext ctx, 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
-
Field Details
-
handshakeTimeoutMillis
protected final long handshakeTimeoutMillis -
timeoutFuture
-
hostname
-
-
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
-
extractSniHostname
-
handlerAdded
Description copied from class:ChannelHandlerAdapter
Do nothing by default, sub-classes may override this method.- Specified by:
handlerAdded
in interfaceChannelHandler
- Overrides:
handlerAdded
in classChannelHandlerAdapter
- Throws:
Exception
-
channelActive
Description copied from class:ChannelInboundHandlerAdapter
CallsChannelHandlerContext.fireChannelActive()
to forward to the nextChannelInboundHandler
in theChannelPipeline
. Sub-classes may override this method to change behavior.- Specified by:
channelActive
in interfaceChannelInboundHandler
- Overrides:
channelActive
in classChannelInboundHandlerAdapter
- Throws:
Exception
-
checkStartTimeout
-
lookup
Description copied from class:SslClientHelloHandler
Kicks off a lookup for the givenClientHello
and returns aFuture
which 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:
lookup
in classSslClientHelloHandler<T>
- Throws:
Exception
- See Also:
-
onLookupComplete
Description copied from class:SslClientHelloHandler
Called upon completion of theSslClientHelloHandler.lookup(ChannelHandlerContext, ByteBuf)
Future
.- Specified by:
onLookupComplete
in classSslClientHelloHandler<T>
- Throws:
Exception
- See Also:
-
lookup
Kicks off a lookup for the given SNI value and returns aFuture
which 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:
-
fireSniCompletionEvent
private static void fireSniCompletionEvent(ChannelHandlerContext ctx, String hostname, Future<?> future)
-