Skip to content

Commit a2a53cb

Browse files
authored
tls: remove deprecated tls.createSecurePair
PR-URL: #57361 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
1 parent c3ed292 commit a2a53cb

16 files changed

+10
-663
lines changed

Diff for: benchmark/tls/secure-pair.js

+1-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
const common = require('../common.js');
33
const bench = common.createBenchmark(main, {
44
dur: [5],
5-
securing: ['SecurePair', 'TLSSocket', 'clear'],
5+
securing: ['TLSSocket', 'clear'],
66
size: [100, 1024, 1024 * 1024],
77
}, {
88
flags: ['--no-warnings'],
@@ -68,9 +68,6 @@ function main({ dur, size, securing }) {
6868
function onProxyConnection(conn) {
6969
const client = net.connect(REDIRECT_PORT, () => {
7070
switch (securing) {
71-
case 'SecurePair':
72-
securePair(conn, client);
73-
break;
7471
case 'TLSSocket':
7572
secureTLSSocket(conn, client);
7673
break;
@@ -83,17 +80,6 @@ function main({ dur, size, securing }) {
8380
});
8481
}
8582

86-
function securePair(conn, client) {
87-
const serverCtx = tls.createSecureContext(options);
88-
const serverPair = tls.createSecurePair(serverCtx, true, true, false);
89-
conn.pipe(serverPair.encrypted);
90-
serverPair.encrypted.pipe(conn);
91-
serverPair.on('error', (error) => {
92-
throw new Error(`Pair error: ${error}`);
93-
});
94-
serverPair.cleartext.pipe(client);
95-
}
96-
9783
function secureTLSSocket(conn, client) {
9884
const serverSocket = new tls.TLSSocket(conn, options);
9985
serverSocket.on('error', (e) => {

Diff for: doc/api/deprecations.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,9 @@ The [`tls.CryptoStream`][] class was removed. Please use
947947

948948
<!-- YAML
949949
changes:
950+
- version: REPLACEME
951+
pr-url: https://github.com/nodejs/node/pull/57361
952+
description: End-of-Life.
950953
- version: v8.0.0
951954
pr-url: https://github.com/nodejs/node/pull/11349
952955
description: Runtime deprecation.
@@ -966,9 +969,9 @@ changes:
966969
description: Runtime deprecation.
967970
-->
968971

969-
Type: Documentation-only
972+
Type: End-of-Life
970973

971-
The [`tls.SecurePair`][] class is deprecated. Please use
974+
The `tls.SecurePair` class is deprecated. Please use
972975
[`tls.TLSSocket`][] instead.
973976

974977
### DEP0044: `util.isArray()`
@@ -1488,6 +1491,9 @@ officially supported API.
14881491

14891492
<!-- YAML
14901493
changes:
1494+
- version: REPLACEME
1495+
pr-url: https://github.com/nodejs/node/pull/57361
1496+
description: End-of-Life.
14911497
- version: v8.0.0
14921498
pr-url: https://github.com/nodejs/node/pull/11349
14931499
description: Runtime deprecation.
@@ -1507,7 +1513,7 @@ changes:
15071513
description: Runtime deprecation.
15081514
-->
15091515

1510-
Type: Runtime
1516+
Type: End-of-Life
15111517

15121518
The `tls.createSecurePair()` API was deprecated in documentation in Node.js
15131519
0.11.3. Users should use `tls.Socket` instead.
@@ -3958,7 +3964,6 @@ deprecated, as their values are guaranteed to be identical to that of `process.f
39583964
[`timeout.unref()`]: timers.md#timeoutunref
39593965
[`tls.CryptoStream`]: tls.md#class-tlscryptostream
39603966
[`tls.SecureContext`]: tls.md#tlscreatesecurecontextoptions
3961-
[`tls.SecurePair`]: tls.md#class-tlssecurepair
39623967
[`tls.TLSSocket`]: tls.md#class-tlstlssocket
39633968
[`tls.checkServerIdentity()`]: tls.md#tlscheckserveridentityhostname-cert
39643969
[`tls.createSecureContext()`]: tls.md#tlscreatesecurecontextoptions

Diff for: doc/api/tls.md

-91
Original file line numberDiff line numberDiff line change
@@ -570,32 +570,6 @@ The `cryptoStream.bytesWritten` property returns the total number of bytes
570570
written to the underlying socket _including_ the bytes required for the
571571
implementation of the TLS protocol.
572572

573-
## Class: `tls.SecurePair`
574-
575-
<!-- YAML
576-
added: v0.3.2
577-
deprecated: v0.11.3
578-
-->
579-
580-
> Stability: 0 - Deprecated: Use [`tls.TLSSocket`][] instead.
581-
582-
Returned by [`tls.createSecurePair()`][].
583-
584-
### Event: `'secure'`
585-
586-
<!-- YAML
587-
added: v0.3.2
588-
deprecated: v0.11.3
589-
-->
590-
591-
The `'secure'` event is emitted by the `SecurePair` object once a secure
592-
connection has been established.
593-
594-
As with checking for the server
595-
[`'secureConnection'`][]
596-
event, `pair.cleartext.authorized` should be inspected to confirm whether the
597-
certificate used is properly authorized.
598-
599573
## Class: `tls.Server`
600574

601575
<!-- YAML
@@ -2125,70 +2099,6 @@ be used to create custom parameters. The key length must be greater than or
21252099
equal to 1024 bits or else an error will be thrown. Although 1024 bits is
21262100
permissible, use 2048 bits or larger for stronger security.
21272101

2128-
## `tls.createSecurePair([context][, isServer][, requestCert][, rejectUnauthorized][, options])`
2129-
2130-
<!-- YAML
2131-
added: v0.3.2
2132-
deprecated: v0.11.3
2133-
changes:
2134-
- version: v5.0.0
2135-
pr-url: https://github.com/nodejs/node/pull/2564
2136-
description: ALPN options are supported now.
2137-
-->
2138-
2139-
> Stability: 0 - Deprecated: Use [`tls.TLSSocket`][] instead.
2140-
2141-
* `context` {Object} A secure context object as returned by
2142-
`tls.createSecureContext()`
2143-
* `isServer` {boolean} `true` to specify that this TLS connection should be
2144-
opened as a server.
2145-
* `requestCert` {boolean} `true` to specify whether a server should request a
2146-
certificate from a connecting client. Only applies when `isServer` is `true`.
2147-
* `rejectUnauthorized` {boolean} If not `false` a server automatically reject
2148-
clients with invalid certificates. Only applies when `isServer` is `true`.
2149-
* `options`
2150-
* `enableTrace`: See [`tls.createServer()`][]
2151-
* `secureContext`: A TLS context object from [`tls.createSecureContext()`][]
2152-
* `isServer`: If `true` the TLS socket will be instantiated in server-mode.
2153-
**Default:** `false`.
2154-
* `server` {net.Server} A [`net.Server`][] instance
2155-
* `requestCert`: See [`tls.createServer()`][]
2156-
* `rejectUnauthorized`: See [`tls.createServer()`][]
2157-
* `ALPNProtocols`: See [`tls.createServer()`][]
2158-
* `SNICallback`: See [`tls.createServer()`][]
2159-
* `session` {Buffer} A `Buffer` instance containing a TLS session.
2160-
* `requestOCSP` {boolean} If `true`, specifies that the OCSP status request
2161-
extension will be added to the client hello and an `'OCSPResponse'` event
2162-
will be emitted on the socket before establishing a secure communication.
2163-
2164-
Creates a new secure pair object with two streams, one of which reads and writes
2165-
the encrypted data and the other of which reads and writes the cleartext data.
2166-
Generally, the encrypted stream is piped to/from an incoming encrypted data
2167-
stream and the cleartext one is used as a replacement for the initial encrypted
2168-
stream.
2169-
2170-
`tls.createSecurePair()` returns a `tls.SecurePair` object with `cleartext` and
2171-
`encrypted` stream properties.
2172-
2173-
Using `cleartext` has the same API as [`tls.TLSSocket`][].
2174-
2175-
The `tls.createSecurePair()` method is now deprecated in favor of
2176-
`tls.TLSSocket()`. For example, the code:
2177-
2178-
```js
2179-
pair = tls.createSecurePair(/* ... */);
2180-
pair.encrypted.pipe(socket);
2181-
socket.pipe(pair.encrypted);
2182-
```
2183-
2184-
can be replaced by:
2185-
2186-
```js
2187-
secureSocket = tls.TLSSocket(socket, options);
2188-
```
2189-
2190-
where `secureSocket` has the same API as `pair.cleartext`.
2191-
21922102
## `tls.createServer([options][, secureConnectionListener])`
21932103

21942104
<!-- YAML
@@ -2556,7 +2466,6 @@ added:
25562466
[`tls.TLSSocket`]: #class-tlstlssocket
25572467
[`tls.connect()`]: #tlsconnectoptions-callback
25582468
[`tls.createSecureContext()`]: #tlscreatesecurecontextoptions
2559-
[`tls.createSecurePair()`]: #tlscreatesecurepaircontext-isserver-requestcert-rejectunauthorized-options
25602469
[`tls.createServer()`]: #tlscreateserveroptions-secureconnectionlistener
25612470
[`tls.getCACertificates()`]: #tlsgetcacertificatestype
25622471
[`tls.getCiphers()`]: #tlsgetciphers

Diff for: lib/internal/tls/secure-pair.js

-87
This file was deleted.

Diff for: lib/tls.js

-6
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ const { Buffer } = require('buffer');
5757
const { canonicalizeIP } = internalBinding('cares_wrap');
5858
const _tls_common = require('_tls_common');
5959
const _tls_wrap = require('_tls_wrap');
60-
const { createSecurePair } = require('internal/tls/secure-pair');
6160
const { validateString } = require('internal/validators');
6261

6362
// Allow {CLIENT_RENEG_LIMIT} client-initiated session renegotiations
@@ -393,8 +392,3 @@ exports.TLSSocket = _tls_wrap.TLSSocket;
393392
exports.Server = _tls_wrap.Server;
394393
exports.createServer = _tls_wrap.createServer;
395394
exports.connect = _tls_wrap.connect;
396-
397-
exports.createSecurePair = internalUtil.deprecate(
398-
createSecurePair,
399-
'tls.createSecurePair() is deprecated. Please use ' +
400-
'tls.TLSSocket instead.', 'DEP0064');

Diff for: test/parallel/test-tls-basic-validations.js

-9
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,6 @@ assert.throws(() => tls.createServer({ ticketKeys: Buffer.alloc(0) }), {
8080
message: /The property 'options\.ticketKeys' must be exactly 48 bytes/
8181
});
8282

83-
assert.throws(
84-
() => tls.createSecurePair({}),
85-
{
86-
message: 'context must be a SecureContext',
87-
code: 'ERR_TLS_INVALID_CONTEXT',
88-
name: 'TypeError',
89-
}
90-
);
91-
9283
{
9384
const buffer = Buffer.from('abcd');
9485
const out = {};

Diff for: test/parallel/test-tls-external-accessor.js

-6
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,3 @@ const tls = require('tls');
1414
assert.throws(() => cctx._external, TypeError);
1515
pctx._external; // eslint-disable-line no-unused-expressions
1616
}
17-
{
18-
const pctx = tls.createSecurePair().credentials.context;
19-
const cctx = { __proto__: pctx };
20-
assert.throws(() => cctx._external, TypeError);
21-
pctx._external; // eslint-disable-line no-unused-expressions
22-
}

Diff for: test/parallel/test-tls-handshake-nohang.js

-32
This file was deleted.

Diff for: test/parallel/test-tls-legacy-deprecated.js

-15
This file was deleted.

0 commit comments

Comments
 (0)