Skip to content

Commit

Permalink
tls: remove deprecated tls.createSecurePair
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasBa committed Mar 7, 2025
1 parent 27f98c3 commit c697c14
Show file tree
Hide file tree
Showing 15 changed files with 5 additions and 580 deletions.
16 changes: 1 addition & 15 deletions benchmark/tls/secure-pair.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const common = require('../common.js');
const bench = common.createBenchmark(main, {
dur: [5],
securing: ['SecurePair', 'TLSSocket', 'clear'],
securing: ['TLSSocket', 'clear'],
size: [100, 1024, 1024 * 1024],
}, {
flags: ['--no-warnings'],
Expand Down Expand Up @@ -68,9 +68,6 @@ function main({ dur, size, securing }) {
function onProxyConnection(conn) {
const client = net.connect(REDIRECT_PORT, () => {
switch (securing) {
case 'SecurePair':
securePair(conn, client);
break;
case 'TLSSocket':
secureTLSSocket(conn, client);
break;
Expand All @@ -83,17 +80,6 @@ function main({ dur, size, securing }) {
});
}

function securePair(conn, client) {
const serverCtx = tls.createSecureContext(options);
const serverPair = tls.createSecurePair(serverCtx, true, true, false);
conn.pipe(serverPair.encrypted);
serverPair.encrypted.pipe(conn);
serverPair.on('error', (error) => {
throw new Error(`Pair error: ${error}`);
});
serverPair.cleartext.pipe(client);
}

function secureTLSSocket(conn, client) {
const serverSocket = new tls.TLSSocket(conn, options);
serverSocket.on('error', (e) => {
Expand Down
5 changes: 4 additions & 1 deletion doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,9 @@ officially supported API.

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/xxxxx

Check warning on line 1492 in doc/api/deprecations.md

View workflow job for this annotation

GitHub Actions / lint-pr-url

pr-url doesn't match the URL of the current PR.
description: End-of-Life.
- version: v8.0.0
pr-url: https://github.com/nodejs/node/pull/11349
description: Runtime deprecation.
Expand All @@ -1507,7 +1510,7 @@ changes:
description: Runtime deprecation.
-->

Type: Runtime
Type: End-of-Life

The `tls.createSecurePair()` API was deprecated in documentation in Node.js
0.11.3. Users should use `tls.Socket` instead.
Expand Down
12 changes: 0 additions & 12 deletions doc/api/tls.md
Original file line number Diff line number Diff line change
Expand Up @@ -570,17 +570,6 @@ The `cryptoStream.bytesWritten` property returns the total number of bytes
written to the underlying socket _including_ the bytes required for the
implementation of the TLS protocol.

## Class: `tls.SecurePair`

<!-- YAML
added: v0.3.2
deprecated: v0.11.3
-->

> Stability: 0 - Deprecated: Use [`tls.TLSSocket`][] instead.
Returned by [`tls.createSecurePair()`][].

### Event: `'secure'`

<!-- YAML
Expand Down Expand Up @@ -2556,7 +2545,6 @@ added:
[`tls.TLSSocket`]: #class-tlstlssocket
[`tls.connect()`]: #tlsconnectoptions-callback
[`tls.createSecureContext()`]: #tlscreatesecurecontextoptions
[`tls.createSecurePair()`]: #tlscreatesecurepaircontext-isserver-requestcert-rejectunauthorized-options
[`tls.createServer()`]: #tlscreateserveroptions-secureconnectionlistener
[`tls.getCACertificates()`]: #tlsgetcacertificatestype
[`tls.getCiphers()`]: #tlsgetciphers
Expand Down
87 changes: 0 additions & 87 deletions lib/internal/tls/secure-pair.js

This file was deleted.

6 changes: 0 additions & 6 deletions lib/tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const { Buffer } = require('buffer');
const { canonicalizeIP } = internalBinding('cares_wrap');
const _tls_common = require('_tls_common');
const _tls_wrap = require('_tls_wrap');
const { createSecurePair } = require('internal/tls/secure-pair');
const { validateString } = require('internal/validators');

// Allow {CLIENT_RENEG_LIMIT} client-initiated session renegotiations
Expand Down Expand Up @@ -393,8 +392,3 @@ exports.TLSSocket = _tls_wrap.TLSSocket;
exports.Server = _tls_wrap.Server;
exports.createServer = _tls_wrap.createServer;
exports.connect = _tls_wrap.connect;

exports.createSecurePair = internalUtil.deprecate(
createSecurePair,
'tls.createSecurePair() is deprecated. Please use ' +
'tls.TLSSocket instead.', 'DEP0064');
9 changes: 0 additions & 9 deletions test/parallel/test-tls-basic-validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,6 @@ assert.throws(() => tls.createServer({ ticketKeys: Buffer.alloc(0) }), {
message: /The property 'options\.ticketKeys' must be exactly 48 bytes/
});

assert.throws(
() => tls.createSecurePair({}),
{
message: 'context must be a SecureContext',
code: 'ERR_TLS_INVALID_CONTEXT',
name: 'TypeError',
}
);

{
const buffer = Buffer.from('abcd');
const out = {};
Expand Down
6 changes: 0 additions & 6 deletions test/parallel/test-tls-external-accessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,3 @@ const tls = require('tls');
assert.throws(() => cctx._external, TypeError);
pctx._external; // eslint-disable-line no-unused-expressions
}
{
const pctx = tls.createSecurePair().credentials.context;
const cctx = { __proto__: pctx };
assert.throws(() => cctx._external, TypeError);
pctx._external; // eslint-disable-line no-unused-expressions
}
32 changes: 0 additions & 32 deletions test/parallel/test-tls-handshake-nohang.js

This file was deleted.

15 changes: 0 additions & 15 deletions test/parallel/test-tls-legacy-deprecated.js

This file was deleted.

25 changes: 0 additions & 25 deletions test/parallel/test-tls-securepair-fiftharg.js

This file was deleted.

28 changes: 0 additions & 28 deletions test/parallel/test-tls-securepair-leak.js

This file was deleted.

Loading

0 comments on commit c697c14

Please sign in to comment.