Top Description Fields Constructors Methods
io.netty.handler.ssl

public abstract Class AbstractSniHandler<T>

extends SslClientHelloHandler<T>
Class Inheritance
Known Direct Subclasses
io.netty.handler.ssl.SniHandler
Imports
io.netty.buffer.ByteBuf, io.netty.channel.ChannelHandlerContext, io.netty.util.CharsetUtil, io.netty.util.concurrent.Future, .ScheduledFuture, java.util.Locale, java.util.concurrent.TimeUnit

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.

Field Summary

Modifier and TypeField and Description
protected final long
private String
private ScheduledFuture<?>
Inherited from io.netty.handler.ssl.SslClientHelloHandler:
MAX_CLIENT_HELLO_LENGTH

Constructor Summary

AccessConstructor and Description
protected
AbstractSniHandler(long
the handshake timeout in milliseconds
handshakeTimeoutMillis
)

protected
AbstractSniHandler(int
the maximum length of the client hello message.
maxClientHelloLength
,
long
the handshake timeout in milliseconds
handshakeTimeoutMillis
)

public

Method Summary

Modifier and TypeMethod and Description
public void
private void
private static String
private static void
public void
handlerAdded(ChannelHandlerContext ctx)

Overrides io.netty.channel.ChannelHandlerAdapter.handlerAdded.

Implements io.netty.channel.ChannelHandler.handlerAdded.

Gets called after the ChannelHandler was added to the actual context and it's ready to handle events.
protected Future<T>
lookup(ChannelHandlerContext ctx, ByteBuf clientHello)

Implements abstract io.netty.handler.ssl.SslClientHelloHandler.lookup.

Kicks off a lookup for the given ClientHello and returns a Future which in turn will notify the onLookupComplete(ChannelHandlerContext, Future) on completion.
protected abstract Future<T>
lookup(ChannelHandlerContext ctx, String hostname)

Kicks off a lookup for the given SNI value and returns a Future which in turn will notify the onLookupComplete(ChannelHandlerContext, String, Future) on completion.

protected void
protected abstract void
onLookupComplete(ChannelHandlerContext ctx, String hostname, Future<T> future)

Called upon completion of the lookup(ChannelHandlerContext, String) Future.

Inherited from io.netty.handler.ssl.SslClientHelloHandler:
bindcloseconnectdecodederegisterdisconnectflushhandlerRemoved0readwrite

Field Detail

handshakeTimeoutMillisback to summary
protected final long handshakeTimeoutMillis
hostnameback to summary
private String hostname
timeoutFutureback to summary
private ScheduledFuture<?> timeoutFuture

Constructor Detail

AbstractSniHandlerback to summary
protected AbstractSniHandler(long handshakeTimeoutMillis)
Parameters
handshakeTimeoutMillis:long

the handshake timeout in milliseconds

AbstractSniHandlerback to summary
protected AbstractSniHandler(int maxClientHelloLength, long handshakeTimeoutMillis)
Parameters
maxClientHelloLength:int

the maximum length of the client hello message.

handshakeTimeoutMillis:long

the handshake timeout in milliseconds

AbstractSniHandlerback to summary
public AbstractSniHandler()

Method Detail

channelActiveback to summary
public void channelActive(ChannelHandlerContext ctx) throws Exception

Overrides io.netty.channel.ChannelInboundHandlerAdapter.channelActive.

Implements io.netty.channel.ChannelInboundHandler.channelActive.

Doc from io.netty.channel.ChannelInboundHandlerAdapter.channelActive.

Calls ChannelHandlerContext#fireChannelActive() to forward to the next ChannelInboundHandler in the ChannelPipeline. Sub-classes may override this method to change behavior.

Annotations
@Override
checkStartTimeoutback to summary
private void checkStartTimeout(final ChannelHandlerContext ctx)
extractSniHostnameback to summary
private static String extractSniHostname(ByteBuf in)
fireSniCompletionEventback to summary
private static void fireSniCompletionEvent(ChannelHandlerContext ctx, String hostname, Future<?> future)
handlerAddedback to summary
public void handlerAdded(ChannelHandlerContext ctx) throws Exception

Overrides io.netty.channel.ChannelHandlerAdapter.handlerAdded.

Implements io.netty.channel.ChannelHandler.handlerAdded.

Doc from io.netty.channel.ChannelHandler.handlerAdded.

Gets called after the ChannelHandler was added to the actual context and it's ready to handle events.

Annotations
@Override
lookupback to summary
protected Future<T> lookup(ChannelHandlerContext ctx, ByteBuf clientHello) throws Exception

Implements abstract io.netty.handler.ssl.SslClientHelloHandler.lookup.

Doc from io.netty.handler.ssl.SslClientHelloHandler.lookup.

Kicks off a lookup for the given ClientHello and returns a Future which in turn will notify the onLookupComplete(ChannelHandlerContext, Future) on completion. See https://tools.ietf.org/html/rfc5246#section-7.4.1.2

struct {
   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;
Annotations
@Override
lookupback to summary
protected abstract Future<T> lookup(ChannelHandlerContext ctx, String hostname) throws Exception

Kicks off a lookup for the given SNI value and returns a Future which in turn will notify the onLookupComplete(ChannelHandlerContext, String, Future) on completion.

See Also
onLookupComplete(ChannelHandlerContext, String, Future)
onLookupCompleteback to summary
protected void onLookupComplete(ChannelHandlerContext ctx, Future<T> future) throws Exception

Implements abstract io.netty.handler.ssl.SslClientHelloHandler.onLookupComplete.

Doc from io.netty.handler.ssl.SslClientHelloHandler.onLookupComplete.

Called upon completion of the lookup(ChannelHandlerContext, ByteBuf) Future.

Annotations
@Override
onLookupCompleteback to summary
protected abstract void onLookupComplete(ChannelHandlerContext ctx, String hostname, Future<T> future) throws Exception

Called upon completion of the lookup(ChannelHandlerContext, String) Future.

See Also
lookup(ChannelHandlerContext, String)