new tls.TLSSocket(socket[, options])
socket
<net.Socket> | <stream.Duplex> 在服务器端,任何Duplex
流。 在客户端,任何net.Socket
实例(对于客户端的通用Duplex
流支持,必须使用tls.connect()
)。options
<Object>enableTrace
: 参见tls.createServer()
isServer
: SSL/TLS 协议是不对称的,TLSSockets 必须知道它们是作为服务器还是客户端运行。 如果true
TLS 套接字将被实例化为服务器。 默认值:false
。server
<net.Server>net.Server
实例。requestCert
: 是否通过请求证书来验证远程对等体。 客户端总是请求服务器证书。 服务器(isServer
为真)可以将requestCert
设置为真以请求客户端证书。rejectUnauthorized
: 参见tls.createServer()
ALPNProtocols
: 参见tls.createServer()
SNICallback
: 参见tls.createServer()
session
<Buffer> 包含 TLS 会话的Buffer
实例。requestOCSP
<boolean> 如果为true
, 则指定将 OCSP 状态请求扩展添加到客户端 hello 并在建立安全通信之前在套接字上触发'OCSPResponse'
事件secureContext
: 使用tls.createSecureContext()
创建的 TLS 上下文对象。 如果secureContext
未提供,则将通过将整个options
对象传给tls.createSecureContext()
来创建。- ...: 如果缺少
secureContext
选项,则使用tls.createSecureContext()
选项。 否则,它们将被忽略。
从现有的 TCP 套接字构造新的 tls.TLSSocket
对象。
socket
<net.Socket> | <stream.Duplex> On the server side, anyDuplex
stream. On the client side, any instance ofnet.Socket
(for genericDuplex
stream support on the client side,tls.connect()
must be used).options
<Object>enableTrace
: Seetls.createServer()
isServer
: The SSL/TLS protocol is asymmetrical, TLSSockets must know if they are to behave as a server or a client. Iftrue
the TLS socket will be instantiated as a server. Default:false
.server
<net.Server> Anet.Server
instance.requestCert
: Whether to authenticate the remote peer by requesting a certificate. Clients always request a server certificate. Servers (isServer
is true) may setrequestCert
to true to request a client certificate.rejectUnauthorized
: Seetls.createServer()
ALPNProtocols
: Seetls.createServer()
SNICallback
: Seetls.createServer()
session
<Buffer> ABuffer
instance containing a TLS session.requestOCSP
<boolean> Iftrue
, specifies that the OCSP status request extension will be added to the client hello and an'OCSPResponse'
event will be emitted on the socket before establishing a secure communicationsecureContext
: TLS context object created withtls.createSecureContext()
. If asecureContext
is not provided, one will be created by passing the entireoptions
object totls.createSecureContext()
.- ...:
tls.createSecureContext()
options that are used if thesecureContext
option is missing. Otherwise, they are ignored.
Construct a new tls.TLSSocket
object from an existing TCP socket.