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

public Class SniHandler

extends AbstractSniHandler<SslContext>
Class Inheritance
Imports
io.netty.buffer.ByteBufAllocator, io.netty.channel.ChannelHandlerContext, io.netty.handler.codec.DecoderException, io.netty.util.AsyncMapping, .DomainNameMapping, .Mapping, .ReferenceCountUtil, io.netty.util.concurrent.Future, .Promise, io.netty.util.internal.ObjectUtil, .PlatformDependent

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 and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private static final SniHandler.Selection
protected final AsyncMapping<String, SslContext>
private volatile SniHandler.Selection
Inherited from io.netty.handler.ssl.AbstractSniHandler:
handshakeTimeoutMillis

Constructor Summary

AccessConstructor and Description
public
SniHandler(Mapping<? super String, ? extends SslContext>
the mapping of domain name to SslContext
mapping
)

Creates a SNI detection handler with configured SslContext maintained by Mapping

public
SniHandler(Mapping<? super String, ? extends SslContext>
the mapping of domain name to SslContext
mapping
,
int
the maximum length of the client hello message
maxClientHelloLength
,
long
the handshake timeout in milliseconds
handshakeTimeoutMillis
)

Creates a SNI detection handler with configured SslContext maintained by Mapping

public
SniHandler(DomainNameMapping<? extends SslContext>
the mapping of domain name to SslContext
mapping
)

Deprecated as a consequence of DomainNameMapping being deprecated.
Creates a SNI detection handler with configured SslContext maintained by DomainNameMapping
public
SniHandler(AsyncMapping<? super String, ? extends SslContext>
the mapping of domain name to SslContext
mapping
)

Creates a SNI detection handler with configured SslContext maintained by AsyncMapping

public
SniHandler(AsyncMapping<? super String, ? extends SslContext>
the mapping of domain name to SslContext
mapping
,
int
the maximum length of the client hello message
maxClientHelloLength
,
long
the handshake timeout in milliseconds
handshakeTimeoutMillis
)

Creates a SNI detection handler with configured SslContext maintained by AsyncMapping

public
SniHandler(Mapping<? super String, ? extends SslContext>
the mapping of domain name to SslContext
mapping
,
long
the handshake timeout in milliseconds
handshakeTimeoutMillis
)

Creates a SNI detection handler with configured SslContext maintained by Mapping

public
SniHandler(AsyncMapping<? super String, ? extends SslContext>
the mapping of domain name to SslContext
mapping
,
long
the handshake timeout in milliseconds
handshakeTimeoutMillis
)

Creates a SNI detection handler with configured SslContext maintained by AsyncMapping

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the selected hostname
hostname
()

protected Future<SslContext>
lookup(ChannelHandlerContext ctx, String hostname)

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

The default implementation will simply call AsyncMapping#map(Object, Promise) but users can override this method to implement custom behavior.
protected SslHandler
newSslHandler(SslContext context, ByteBufAllocator allocator)

Returns a new SslHandler using the given SslContext and ByteBufAllocator.

protected final void
protected void
replaceHandler(ChannelHandlerContext ctx, String hostname, SslContext sslContext)

The default implementation of this method will simply replace this SniHandler instance with a SslHandler.

public SslContext

Returns:

the selected SslContext
sslContext
()

Inherited from io.netty.handler.ssl.AbstractSniHandler:
channelActivehandlerAddedlookuponLookupComplete

Field Detail

EMPTY_SELECTIONback to summary
private static final SniHandler.Selection EMPTY_SELECTION
mappingback to summary
protected final AsyncMapping<String, SslContext> mapping
selectionback to summary
private volatile SniHandler.Selection selection

Constructor Detail

SniHandlerback to summary
public SniHandler(Mapping<? super String, ? extends SslContext> mapping)

Creates a SNI detection handler with configured SslContext maintained by Mapping

Parameters
mapping:Mapping<? super String, ? extends SslContext>

the mapping of domain name to SslContext

SniHandlerback to summary
public SniHandler(Mapping<? super String, ? extends SslContext> mapping, int maxClientHelloLength, long handshakeTimeoutMillis)

Creates a SNI detection handler with configured SslContext maintained by Mapping

Parameters
mapping:Mapping<? super String, ? extends SslContext>

the mapping of domain name to SslContext

maxClientHelloLength:int

the maximum length of the client hello message

handshakeTimeoutMillis:long

the handshake timeout in milliseconds

SniHandlerback to summary
public SniHandler(DomainNameMapping<? extends SslContext> mapping)

Deprecated

as a consequence of DomainNameMapping being deprecated. See corresponding docs for further information.

Creates a SNI detection handler with configured SslContext maintained by DomainNameMapping

Parameters
mapping:DomainNameMapping<? extends SslContext>

the mapping of domain name to SslContext

SniHandlerback to summary
public SniHandler(AsyncMapping<? super String, ? extends SslContext> mapping)

Creates a SNI detection handler with configured SslContext maintained by AsyncMapping

Parameters
mapping:AsyncMapping<? super String, ? extends SslContext>

the mapping of domain name to SslContext

Annotations
@SuppressWarnings:unchecked
SniHandlerback to summary
public SniHandler(AsyncMapping<? super String, ? extends SslContext> mapping, int maxClientHelloLength, long handshakeTimeoutMillis)

Creates a SNI detection handler with configured SslContext maintained by AsyncMapping

Parameters
mapping:AsyncMapping<? super String, ? extends SslContext>

the mapping of domain name to SslContext

maxClientHelloLength:int

the maximum length of the client hello message

handshakeTimeoutMillis:long

the handshake timeout in milliseconds

Annotations
@SuppressWarnings:unchecked
SniHandlerback to summary
public SniHandler(Mapping<? super String, ? extends SslContext> mapping, long handshakeTimeoutMillis)

Creates a SNI detection handler with configured SslContext maintained by Mapping

Parameters
mapping:Mapping<? super String, ? extends SslContext>

the mapping of domain name to SslContext

handshakeTimeoutMillis:long

the handshake timeout in milliseconds

SniHandlerback to summary
public SniHandler(AsyncMapping<? super String, ? extends SslContext> mapping, long handshakeTimeoutMillis)

Creates a SNI detection handler with configured SslContext maintained by AsyncMapping

Parameters
mapping:AsyncMapping<? super String, ? extends SslContext>

the mapping of domain name to SslContext

handshakeTimeoutMillis:long

the handshake timeout in milliseconds

Method Detail

hostnameback to summary
public String hostname()
Returns:String

the selected hostname

lookupback to summary
protected Future<SslContext> lookup(ChannelHandlerContext ctx, String hostname) throws Exception

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

The default implementation will simply call AsyncMapping#map(Object, Promise) but users can override this method to implement custom behavior.

Annotations
@Override
See Also
AsyncMapping#map(Object, Promise)
newSslHandlerback to summary
protected SslHandler newSslHandler(SslContext context, ByteBufAllocator allocator)

Returns a new SslHandler using the given SslContext and ByteBufAllocator. Users may override this method to implement custom behavior.

onLookupCompleteback to summary
protected final void onLookupComplete(ChannelHandlerContext ctx, String hostname, Future<SslContext> future) throws Exception

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

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

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

Annotations
@Override
replaceHandlerback to summary
protected void replaceHandler(ChannelHandlerContext ctx, String hostname, SslContext sslContext) throws Exception

The default implementation of this method will simply replace this SniHandler instance with a SslHandler. Users may override this method to implement custom behavior. Please be aware that this method may get called after a client has already disconnected and custom implementations must take it into consideration when overriding this method. It's also possible for the hostname argument to be null.

sslContextback to summary
public SslContext sslContext()
Returns:SslContext

the selected SslContext

io.netty.handler.ssl back to summary

private final Class SniHandler.AsyncMappingAdapter

extends Object
implements AsyncMapping<String, SslContext>
Class Inheritance
All Implemented Interfaces
io.netty.util.AsyncMapping

Field Summary

Modifier and TypeField and Description
private final Mapping<? super String, ? extends SslContext>

Constructor Summary

AccessConstructor and Description
private
AsyncMappingAdapter(Mapping<? super String, ? extends SslContext> mapping)

Method Summary

Modifier and TypeMethod and Description
public Future<SslContext>
map(String input, Promise<SslContext> promise)

Implements io.netty.util.AsyncMapping.map.

Returns the Future that will provide the result of the mapping.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mappingback to summary
private final Mapping<? super String, ? extends SslContext> mapping

Constructor Detail

AsyncMappingAdapterback to summary
private AsyncMappingAdapter(Mapping<? super String, ? extends SslContext> mapping)

Method Detail

mapback to summary
public Future<SslContext> map(String input, Promise<SslContext> promise)

Implements io.netty.util.AsyncMapping.map.

Doc from io.netty.util.AsyncMapping.map.

Returns the Future that will provide the result of the mapping. The given Promise will be fulfilled when the result is available.

Annotations
@Override
io.netty.handler.ssl back to summary

private final Class SniHandler.Selection

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final SslContext
pack-priv final String

Constructor Summary

AccessConstructor and Description
pack-priv
Selection(SslContext context, String hostname)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contextback to summary
pack-priv final SslContext context
hostnameback to summary
pack-priv final String hostname

Constructor Detail

Selectionback to summary
pack-priv Selection(SslContext context, String hostname)