Skip to content

Commit 3abf9d5

Browse files
jhamhaderjasnell
authored andcommitted
doc, tls: deprecate createSecurePair
createSecurePair uses tls_legacy and the legacy Connection from node_crypto.cc. Deprecate them in favor of TLSSocket. PR-URL: #6063 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent d6237aa commit 3abf9d5

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

doc/api/tls.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ the total bytes written to the socket, *including the TLS overhead*.
168168

169169
## Class: SecurePair
170170

171+
Stability: 0 - Deprecated: Use [`tls.TLSSocket`][] instead.
172+
171173
Returned by tls.createSecurePair.
172174

173175
### Event: 'secure'
@@ -379,9 +381,9 @@ Construct a new TLSSocket object from an existing TCP socket.
379381

380382
- `server`: An optional [`net.Server`][] instance
381383

382-
- `requestCert`: Optional, see [`tls.createSecurePair()`][]
384+
- `requestCert`: Optional, see [`tls.createServer()`][]
383385

384-
- `rejectUnauthorized`: Optional, see [`tls.createSecurePair()`][]
386+
- `rejectUnauthorized`: Optional, see [`tls.createServer()`][]
385387

386388
- `NPNProtocols`: Optional, see [`tls.createServer()`][]
387389

@@ -745,6 +747,8 @@ publicly trusted list of CAs as given in
745747

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

750+
Stability: 0 - Deprecated: Use [`tls.TLSSocket`][] instead.
751+
748752
Creates a new secure pair object with two streams, one of which reads and writes
749753
the encrypted data and the other of which reads and writes the cleartext data.
750754
Generally, the encrypted stream is piped to/from an incoming encrypted data
@@ -770,6 +774,23 @@ stream.
770774

771775
NOTE: `cleartext` has the same API as [`tls.TLSSocket`][]
772776

777+
**Deprecated** `tls.createSecurePair()` is now deprecated in favor of
778+
`tls.TLSSocket()`. For example:
779+
780+
```js
781+
pair = tls.createSecurePair( ... );
782+
pair.encrypted.pipe(socket);
783+
socket.pipe(pair.encrypted);
784+
```
785+
786+
can be replaced with:
787+
788+
```js
789+
secure_socket = tls.TLSSocket(socket, options);
790+
```
791+
792+
where `secure_socket` has the same API as `pair.cleartext`.
793+
773794
## tls.createServer(options[, secureConnectionListener])
774795

775796
Creates a new [tls.Server][]. The `connectionListener` argument is

0 commit comments

Comments
 (0)