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 private java.lang.String
hostname
-
Fields inherited from class io.netty.handler.codec.ByteToMessageDecoder
COMPOSITE_CUMULATOR, MERGE_CUMULATOR
-
-
Constructor Summary
Constructors Constructor Description AbstractSniHandler()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private static java.lang.String
extractSniHostname(ByteBuf in)
private void
fireSniCompletionEvent(ChannelHandlerContext ctx, java.lang.String hostname, Future<T> future)
protected Future<T>
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.protected abstract Future<T>
lookup(ChannelHandlerContext ctx, java.lang.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, 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
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, 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
handlerAdded, handlerRemoved
-
-
-
-
Method Detail
-
extractSniHostname
private static java.lang.String extractSniHostname(ByteBuf in)
-
lookup
protected Future<T> lookup(ChannelHandlerContext ctx, ByteBuf clientHello) throws java.lang.Exception
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_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:
lookup
in 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:SslClientHelloHandler
Called upon completion of theSslClientHelloHandler.lookup(ChannelHandlerContext, ByteBuf)
Future
.- Specified by:
onLookupComplete
in 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 aFuture
which 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)
-
fireSniCompletionEvent
private void fireSniCompletionEvent(ChannelHandlerContext ctx, java.lang.String hostname, Future<T> future)
-
-