'secureConnection' 事件


'secureConnection' 事件在新连接的握手过程成功完成后触发。 监听器回调在调用时传入一个参数:

tlsSocket.authorized 属性是一个 boolean,指示客户端是否已通过服务器提供的证书颁发机构之一进行验证。 如果 tlsSocket.authorizedfalse,则设置 socket.authorizationError 来描述授权失败的方式。 根据 TLS 服务器的设置,可能仍会接受未经授权的连接。

tlsSocket.alpnProtocol 属性是包含所选 ALPN 协议的字符串。 当 ALPN 没有选择协议时,则 tlsSocket.alpnProtocol 等于 false

tlsSocket.servername 属性是包含通过 SNI 请求的服务器名称的字符串。

The 'secureConnection' event is emitted after the handshaking process for a new connection has successfully completed. The listener callback is passed a single argument when called:

The tlsSocket.authorized property is a boolean indicating whether the client has been verified by one of the supplied Certificate Authorities for the server. If tlsSocket.authorized is false, then socket.authorizationError is set to describe how authorization failed. Depending on the settings of the TLS server, unauthorized connections may still be accepted.

The tlsSocket.alpnProtocol property is a string that contains the selected ALPN protocol. When ALPN has no selected protocol, tlsSocket.alpnProtocol equals false.

The tlsSocket.servername property is a string containing the server name requested via SNI.