public class SniHandler extends AbstractSniHandler<SslContext>
为服务器端SSL启用SNI (Server Name Indication)扩展。 对于支持SNI的客户端,服务器可以在单个IP上绑定多个主机名。 客户端将在握手数据中发送主机名,以便服务器可以决定为主机名选择哪个证书。
ByteToMessageDecoder.Cumulator
ChannelHandler.Sharable
Modifier and Type | Field and Description |
---|---|
protected AsyncMapping<java.lang.String,SslContext> |
mapping |
COMPOSITE_CUMULATOR, MERGE_CUMULATOR
Constructor and Description |
---|
SniHandler(AsyncMapping<? super java.lang.String,? extends SslContext> mapping)
创建一个SNI检测处理程序,配置 SslContext ,由AsyncMapping 维护
|
SniHandler(DomainNameMapping<? extends SslContext> mapping)
创建一个由 DomainNameMapping 维护的配置SslContext 的SNI检测处理程序
|
SniHandler(Mapping<? super java.lang.String,? extends SslContext> mapping)
创建一个由 Mapping 维护的配置SslContext 的SNI检测处理程序
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
hostname() |
protected Future<SslContext> |
lookup(ChannelHandlerContext ctx, java.lang.String hostname)
默认实现只会调用
AsyncMapping.map(Object, Promise) ,但用户可以重写此方法来实现自定义行为。
|
protected void |
onLookupComplete(ChannelHandlerContext ctx, java.lang.String hostname, Future<SslContext> future)
|
protected void |
replaceHandler(ChannelHandlerContext ctx, java.lang.String hostname, SslContext sslContext)
此方法的默认实现将只需更换 this SniHandler 用实例SslHandler 。
|
SslContext |
sslContext() |
bind, close, connect, decode, deregister, disconnect, flush, read, write
actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggered
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
ensureNotSharable, handlerAdded, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
exceptionCaught, handlerAdded, handlerRemoved
protected final AsyncMapping<java.lang.String,SslContext> mapping
public SniHandler(Mapping<? super java.lang.String,? extends SslContext> mapping)
SslContext
由Mapping
维护
mapping
- 域名映射到SslContext
public SniHandler(DomainNameMapping<? extends SslContext> mapping)
DomainNameMapping
维护的配置SslContext
的SNI检测处理程序
mapping
- 域名映射到SslContext
public SniHandler(AsyncMapping<? super java.lang.String,? extends SslContext> mapping)
AsyncMapping
维护的配置SslContext
的SNI检测处理程序
mapping
- 域名映射到SslContext
public java.lang.String hostname()
public SslContext sslContext()
SslContext
protected Future<SslContext> lookup(ChannelHandlerContext ctx, java.lang.String hostname) throws java.lang.Exception
AsyncMapping.map(Object, Promise)
,但用户可以重写此方法来实现自定义行为。
lookup
在课堂
AbstractSniHandler<SslContext>
java.lang.Exception
AsyncMapping.map(Object, Promise)
protected final void onLookupComplete(ChannelHandlerContext ctx, java.lang.String hostname, Future<SslContext> future) throws java.lang.Exception
AbstractSniHandler
onLookupComplete
在课堂
AbstractSniHandler<SslContext>
java.lang.Exception
AbstractSniHandler.lookup(ChannelHandlerContext, String)
protected void replaceHandler(ChannelHandlerContext ctx, java.lang.String hostname, SslContext sslContext) throws java.lang.Exception
this
SniHandler
用实例SslHandler
。
用户可以重写此方法来实现自定义行为。
请注意,在客户端断开连接后,可能会调用此方法,并且在覆盖此方法时,自定义实现必须考虑此方法。
主机名参数也可以是null
。
java.lang.Exception
Copyright © 2008–2018 The Netty Project. All rights reserved.