server.addContext(hostname, context)
-
hostname
<string> SNI 主机名或通配符(例如'*'
)¥
hostname
<string> A SNI host name or wildcard (e.g.'*'
) -
context
<Object> | <tls.SecureContext> 包含tls.createSecureContext()
options
参数(例如key
、cert
、ca
等)的任何可能属性的对象,或使用tls.createSecureContext()
本身创建的 TLS 上下文对象。¥
context
<Object> | <tls.SecureContext> An object containing any of the possible properties from thetls.createSecureContext()
options
arguments (e.g.key
,cert
,ca
, etc), or a TLS context object created withtls.createSecureContext()
itself.
server.addContext()
方法添加了安全的上下文,如果客户端请求的 SNI 名称与提供的 hostname
(或通配符)匹配,则将使用该上下文。
¥The server.addContext()
method adds a secure context that will be used if
the client request's SNI name matches the supplied hostname
(or wildcard).
当有多个匹配的上下文时,使用最近添加的一个。
¥When there are multiple matching contexts, the most recently added one is used.