阿西河

所有教程

公众号
🌙
阿西河前端的公众号

我的收藏

    最近访问  (文章)

      教程列表

      抓包专区
      测试专区

      Node.js tls.createSecurePair 废弃

      Node.js tls.createSecurePair 废弃

      tls.createSecurePair([context][, isServer][, requestCert][, rejectUnauthorized][, options])

      版本历史

      版本变更
      v5.0.0ALPN options are supported now.
      v0.11.3废弃于: v0.11.3
      v0.3.2新增于: v0.3.2

      废弃: 改为使用 tls.TLSSocket 。

      • context < Object> A secure context object as returned by tls.createSecureContext()
      • isServer < boolean> true to specify that this TLS connection should be opened as a server.
      • requestCert < boolean> true to specify whether a server should request a certificate from a connecting client. Only applies when isServer is true.
      • rejectUnauthorized < boolean> If not false a server automatically reject clients with invalid certificates. Only applies when isServer is true.
      • options
        • secureContext: A TLS context object from tls.createSecureContext()
        • isServer: If true the TLS socket will be instantiated in server-mode. Default: false.
        • server < net.Server> A net.Server instance
        • requestCert: See tls.createServer()
        • rejectUnauthorized: See tls.createServer()
        • ALPNProtocols: See tls.createServer()
        • SNICallback: See tls.createServer()
        • session < Buffer> A Buffer instance containing a TLS session.
        • requestOCSP < boolean> If true, 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 communication.

      Creates a new secure pair object with two streams, one of which reads and writes the encrypted data and the other of which reads and writes the cleartext data. Generally, the encrypted stream is piped to/from an incoming encrypted data stream and the cleartext one is used as a replacement for the initial encrypted stream.

      tls.createSecurePair() returns a tls.SecurePair object with cleartext and encrypted stream properties.

      Using cleartext has the same API as tls.TLSSocket.

      The tls.createSecurePair() method is now deprecated in favor of tls.TLSSocket(). For example, the code:

      pair = tls.createSecurePair(/* ... */);
      pair.encrypted.pipe(socket);
      socket.pipe(pair.encrypted);
      

      can be replaced by:

      secureSocket = tls.TLSSocket(socket, options);
      

      where secureSocket has the same API as pair.cleartext.


      更多内容请参考:Node.js tls 安全传输层,或者通过 点击对应菜单 进行查看;


      目录
      本文目录
      目录