tlsSocket.renegotiate(options, callback)


  • options <Object>
    • rejectUnauthorized <boolean> 如果不是 false,服务器证书将会根据提供的 CA 列表进行验证。如果验证失败,会触发 'error' 事件;err.code 包含 OpenSSL 错误代码。默认值: true
    • requestCert
  • callback <Function> 如果 renegotiate() 返回 true,回调会被附加一次到 'secure' 事件上。如果 renegotiate() 返回 falsecallback 将在下一个周期被调用并带有一个错误,除非 tlsSocket 已被销毁,在这种情况下 callback 将根本不会被调用。
  • 返回:<boolean> 如果重新协商已启动,则为 true,否则为 false

tlsSocket.renegotiate() 方法会启动一个 TLS 重新协商过程。完成后,callback 函数将接收一个参数,该参数要么是 Error(如果请求失败),要么是 null

【The tlsSocket.renegotiate() method initiates a TLS renegotiation process. Upon completion, the callback function will be passed a single argument that is either an Error (if the request failed) or null.】

此方法可在建立安全连接后用于请求对端的证书。

【This method can be used to request a peer's certificate after the secure connection has been established.】

作为服务器运行时,套接字将在 handshakeTimeout 超时后因错误而被销毁。

【When running as the server, the socket will be destroyed with an error after handshakeTimeout timeout.】

对于 TLSv1.3,无法发起重新协商,协议不支持此功能。

【For TLSv1.3, renegotiation cannot be initiated, it is not supported by the protocol.】