Commit 1ad01d3f39d for nodejs

commit 1ad01d3f39d2a760b19233ef112d3e25929f98de
Author: Tim Perry <pimterry@gmail.com>
Date:   Mon Nov 23 09:55:38 2026 +0100

    tls: disable TLS renegotiation by default, with a warning if enabled

    This is the next step in the deprecation process for this, for v27. For
    now we'll keep this available on an opt-in basis, but the following step
    will be to remove it completely.

    One case here does not warn: enabling renegotiation client side
    explicitly, and using it just to accept server-initiated renegotiations.
    This will be retained for legacy server support scenarios. Initiating
    renegotiation from the client side still emits a warning.

    Signed-off-by: Tim Perry <pimterry@gmail.com>
    PR-URL: https://github.com/nodejs/node/pull/67618
    Reviewed-By: Filip Skokan <panva.ip@gmail.com>
    Reviewed-By: James M Snell <jasnell@gmail.com>

diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md
index b2e6032af6e..50c7a7e357f 100644
--- a/doc/api/deprecations.md
+++ b/doc/api/deprecations.md
@@ -4885,18 +4885,21 @@ Use global `TextDecoder` and `TextEncoder` instead.

 <!-- YAML
 changes:
+  - version: REPLACEME
+    pr-url: https://github.com/nodejs/node/pull/67618
+    description: Runtime deprecation. Renegotiation is disabled by default.
   - version: REPLACEME
     pr-url: https://github.com/nodejs/node/pull/67532
     description: Documentation-only deprecation
                  with `--pending-deprecation` support.
 -->

-Type: Documentation-only (supports [`--pending-deprecation`][])
+Type: Runtime

-TLS renegotiation is deprecated and will be disabled by default in future.
-This functionality will be largely removed in a subsequent release. Only a
-client accepting server-initiated renegotiation requests is expected to
-remain supported, and on an opt-in basis for legacy server compatibility.
+TLS renegotiation is deprecated and is disabled by default. This functionality
+will be largely removed in a subsequent release. Only a client accepting
+server-initiated renegotiation requests is expected to remain supported, and
+on an opt-in basis for legacy server compatibility.

 This only affects TLS 1.2. TLS 1.3 removed renegotiation from the standard,
 and so this has never been supported.
@@ -4909,24 +4912,27 @@ an existing connection should create a new connection.
 This affects multiple TLS APIs:

 * Node.js TLS clients needing to initiate renegotiation locally, or accept
-  renegotiation requested by the server, should opt in by setting the
-  `allowRenegotiation` option of [`tls.connect()`][].
+  renegotiation requested by the server, must opt in by setting the
+  `allowRenegotiation` option of [`tls.connect()`][]. Accepting renegotiation
+  requested by the server does not emit a deprecation warning.
 * Node.js TLS servers needing to initiate renegotiation locally, or accept
-  renegotiation requested by the client, should opt in by setting the
-  `allowRenegotiation` option of [`tls.createServer()`][].
+  renegotiation requested by the client, must opt in by setting the
+  `allowRenegotiation` option of [`tls.createServer()`][], which emits a
+  deprecation warning.
   If renegotiation by clients is removed in future, setting this option to
   `true` on a server will throw an error.
 * In either case, initiating renegotiation ([`tlsSocket.renegotiate()`][])
-  should be avoided by using alternative mechanisms. When renegotiation is
-  disabled by default this method will only work on connections created
-  with the `allowRenegotiation` option, and will throw an error if not.
+  emits a deprecation warning, and should be avoided by using alternative
+  mechanisms. This method only works on connections created with the
+  `allowRenegotiation` option, and will throw an error if not.
   If initiating renegotiation is removed in future, this method will throw
   an error.
-* Using [`tlsSocket.disableRenegotiation()`][] to disable renegotiation will
-  no longer be necessary when it is disabled by default. This will become a
-  no-op in most configurations.
+* Using [`tlsSocket.disableRenegotiation()`][] to disable renegotiation is
+  no longer necessary. It is a no-op unless the connection was created with
+  the `allowRenegotiation` option.
 * The `tls.CLIENT_RENEG_LIMIT` and `tls.CLIENT_RENEG_WINDOW` properties which
-  limit renegotiation will become unused in default configurations.
+  limit renegotiation are unused unless a server sets the `allowRenegotiation`
+  option. Reading or writing either emits a deprecation warning.
   If renegotiation by clients is removed in future these are likely to be
   removed.

diff --git a/doc/api/tls.md b/doc/api/tls.md
index 08c5e66ef62..d82ea70e2c8 100644
--- a/doc/api/tls.md
+++ b/doc/api/tls.md
@@ -231,14 +231,14 @@ threshold is exceeded. The limits are configurable:
   in seconds. **Default:** `600` (10 minutes).

 The default renegotiation limits should not be modified without a full
-understanding of the implications and risks.
+understanding of the implications and risks. Reading or writing either
+property emits a deprecation warning (see [DEP0213][]).

 TLSv1.3 does not support renegotiation.

-Renegotiation is deprecated (see [DEP0213][]). A future version of Node.js will
-disable it by default, for servers and clients. The `allowRenegotiation` option
-of [`tls.createServer()`][] and [`tls.connect()`][] can be set to `false` to
-disable it now, or to `true` to keep it enabled when that default changes.
+Renegotiation is deprecated (see [DEP0213][]) and is disabled by default, for
+servers and clients. The `allowRenegotiation` option of [`tls.createServer()`][]
+and [`tls.connect()`][] can be set to `true` to enable it.

 ### Session resumption

@@ -906,6 +906,9 @@ connection is open.
 <!-- YAML
 added: v0.11.4
 changes:
+  - version: REPLACEME
+    pr-url: https://github.com/nodejs/node/pull/67618
+    description: The `allowRenegotiation` option now defaults to `false`.
   - version: REPLACEME
     pr-url: https://github.com/nodejs/node/pull/67532
     description: The `allowRenegotiation` option is now supported.
@@ -1136,9 +1139,9 @@ deprecated: REPLACEME
 Disables TLS renegotiation for this `TLSSocket` instance. Once called, attempts
 to renegotiate will trigger an `'error'` event on the `TLSSocket`.

-Set `allowRenegotiation: false` when creating the server or connection
-instead. This method has no effect on a connection created that way, where the
-peer's attempts to renegotiate are refused without an error.
+Renegotiation is disabled by default, and the peer's attempts to renegotiate
+are then refused without an error. This method only has an effect on a
+connection created with `allowRenegotiation: true`.

 ### `tlsSocket.enableTrace()`

@@ -1604,6 +1607,10 @@ Returns the numeric representation of the remote port. For example, `443`.
 added: v0.11.8
 deprecated: REPLACEME
 changes:
+  - version: REPLACEME
+    pr-url: https://github.com/nodejs/node/pull/67618
+    description: Runtime deprecation. This method now fails unless the
+                 connection was created with the `allowRenegotiation` option.
   - version: v18.0.0
     pr-url: https://github.com/nodejs/node/pull/41678
     description: Passing an invalid callback to the `callback` argument
@@ -1641,11 +1648,9 @@ When running as the server, the socket will be destroyed with an error after
 For TLSv1.3, renegotiation cannot be initiated, it is not supported by the
 protocol.

-If the connection was created with `allowRenegotiation: false`, this method
+Unless the connection was created with `allowRenegotiation: true`, this method
 returns `false` and `callback` is called with an
-[`ERR_TLS_RENEGOTIATION_DISABLED`][] error. A future version of Node.js will
-disable renegotiation by default, and this method will then only work on
-connections created with `allowRenegotiation: true`.
+[`ERR_TLS_RENEGOTIATION_DISABLED`][] error.

 ### `tlsSocket.servername`

@@ -1765,6 +1770,9 @@ was present (see [CVE-2021-44531][]). Applications that wish to accept
 <!-- YAML
 added: v0.11.3
 changes:
+  - version: REPLACEME
+    pr-url: https://github.com/nodejs/node/pull/67618
+    description: The `allowRenegotiation` option now defaults to `false`.
   - version: REPLACEME
     pr-url: https://github.com/nodejs/node/pull/67532
     description: The `allowRenegotiation` option is now supported.
@@ -1866,8 +1874,8 @@ changes:
     than `minDHSize`, the TLS connection is destroyed and an error is thrown.
     **Default:** `1024`.
   * `allowRenegotiation` {boolean} If `true`, the client accepts renegotiation
-    requested by the server. A future version of Node.js will change this default
-    to `false` (see [DEP0213][]). **Default:** `true`.
+    requested by the server. Renegotiation is deprecated (see [DEP0213][]).
+    **Default:** `false`.
   * `highWaterMark` {number} Consistent with the readable stream `highWaterMark` parameter.
     **Default:** `16 * 1024`.
   * `timeout`: {number} If set and if a socket is created internally, will call
@@ -2240,6 +2248,9 @@ permissible, use 2048 bits or larger for stronger security.
 <!-- YAML
 added: v0.3.2
 changes:
+  - version: REPLACEME
+    pr-url: https://github.com/nodejs/node/pull/67618
+    description: The `allowRenegotiation` option now defaults to `false`.
   - version: REPLACEME
     pr-url: https://github.com/nodejs/node/pull/67532
     description: The `allowRenegotiation` option is now supported.
@@ -2283,10 +2294,10 @@ changes:
   * `allowRenegotiation` {boolean} If `true`, connections to the server may be
     renegotiated, either when requested by the client or through local calls to
     [`tlsSocket.renegotiate()`][]. Renegotiation is deprecated (see
-    [DEP0213][]) and future versions will set this default to `false`.
+    [DEP0213][]), and setting this to `true` emits a deprecation warning.
     Setting this to `true` throws [`ERR_TLS_RENEGOTIATION_UNSUPPORTED`][]
     where the TLS library does not support renegotiation on servers.
-    **Default:** `true`.
+    **Default:** `false`.
   * `ALPNProtocols` {string\[]|Buffer|TypedArray|DataView} An array of strings,
     or a single `Buffer`, `TypedArray`, or `DataView` containing the supported
     ALPN protocols. Buffers should have the format `[len][name][len][name]...`
diff --git a/lib/internal/tls/common.js b/lib/internal/tls/common.js
index 95a74ada326..b963aa75dbd 100644
--- a/lib/internal/tls/common.js
+++ b/lib/internal/tls/common.js
@@ -158,8 +158,12 @@ function translatePeerCertificate(c) {
   return c;
 }

+// Backs tls.CLIENT_RENEG_LIMIT and tls.CLIENT_RENEG_WINDOW.
+const renegotiationLimits = { limit: 3, window: 600 };
+
 module.exports = {
   SecureContext,
+  renegotiationLimits,
   createSecureContext,
   translatePeerCertificate,
 };
diff --git a/lib/internal/tls/wrap.js b/lib/internal/tls/wrap.js
index cb55387f9b7..67643edef0e 100644
--- a/lib/internal/tls/wrap.js
+++ b/lib/internal/tls/wrap.js
@@ -35,7 +35,6 @@ const {
 const {
   assertCrypto,
   getDeprecationWarningEmitter,
-  isPendingDeprecation,
   kEmptyObject,
 } = require('internal/util');

@@ -105,12 +104,8 @@ const {
 } = require('internal/crypto/x509');
 const emitRenegotiationDeprecation = getDeprecationWarningEmitter(
   'DEP0213',
-  'TLS renegotiation is deprecated and will be disabled by default. Only ' +
-  "clients setting allowRenegotiation to accept a server's request will " +
-  'remain supported.',
-  undefined,
-  false,
-  isPendingDeprecation,
+  'TLS renegotiation is deprecated. Only clients setting allowRenegotiation ' +
+  "to accept a server's request will remain supported.",
 );
 const traceTls = getOptionValue('--trace-tls');
 const tlsKeylog = getOptionValue('--tls-keylog');
@@ -228,7 +223,7 @@ function onhandshakestart(now) {
   if (lastHandshakeTime === 0)
     return;

-  if ((now - lastHandshakeTime) >= tls.CLIENT_RENEG_WINDOW * 1000)
+  if ((now - lastHandshakeTime) >= common.renegotiationLimits.window * 1000)
     this.handshakes = 1;
   else
     this.handshakes++;
@@ -237,7 +232,7 @@ function onhandshakestart(now) {

   assert(owner._tlsOptions.isServer);

-  if (this.handshakes > tls.CLIENT_RENEG_LIMIT) {
+  if (this.handshakes > common.renegotiationLimits.limit) {
     owner._emitTLSError(new ERR_TLS_SESSION_ATTACK());
     return;
   }
@@ -250,9 +245,12 @@ function validateAllowRenegotiation(allowRenegotiation, isServer) {
   if (allowRenegotiation === undefined)
     return;
   validateBoolean(allowRenegotiation, 'options.allowRenegotiation');
-  // BoringSSL servers always refuse renegotiation.
-  if (allowRenegotiation && isServer && isBoringSSL)
-    throw new ERR_TLS_RENEGOTIATION_UNSUPPORTED();
+  if (allowRenegotiation && isServer) {
+    // BoringSSL servers always refuse renegotiation.
+    if (isBoringSSL)
+      throw new ERR_TLS_RENEGOTIATION_UNSUPPORTED();
+    emitRenegotiationDeprecation();
+  }
 }

 function onhandshakedone() {
@@ -1012,7 +1010,7 @@ TLSSocket.prototype._init = function(socket, wrap) {
   if (requestCert || rejectUnauthorized)
     ssl.setVerifyMode(requestCert, rejectUnauthorized);

-  if (options.allowRenegotiation === false)
+  if (options.allowRenegotiation !== true)
     ssl.disableRenegotiation();

   // Only call .onkeylog if there is a keylog listener.
@@ -1162,7 +1160,7 @@ TLSSocket.prototype.renegotiate = function(options, callback) {
   if (this.destroyed)
     return;

-  if (this._tlsOptions.allowRenegotiation === false) {
+  if (this._tlsOptions.allowRenegotiation !== true) {
     if (callback) {
       process.nextTick(callback, new ERR_TLS_RENEGOTIATION_DISABLED());
     }
@@ -1275,13 +1273,6 @@ TLSSocket.prototype._finishInit = function() {
         'alpn', this.alpnProtocol,
         'servername', this.servername);

-  // A second completed handshake is a renegotiation.
-  if (this._secureEstablished &&
-      (this._tlsOptions.isServer ||
-       this._tlsOptions.allowRenegotiation !== true)) {
-    emitRenegotiationDeprecation();
-  }
-
   this._secureEstablished = true;
   if (this._tlsOptions.handshakeTimeout > 0)
     this.setTimeout(0, this._handleTimeout);
diff --git a/lib/tls.js b/lib/tls.js
index 288d783721d..13171847c7e 100644
--- a/lib/tls.js
+++ b/lib/tls.js
@@ -84,8 +84,31 @@ const {
 // every {CLIENT_RENEG_WINDOW} seconds. An error event is emitted if more
 // renegotiations are seen. The settings are applied to all remote client
 // connections.
-exports.CLIENT_RENEG_LIMIT = 3;
-exports.CLIENT_RENEG_WINDOW = 600;
+const emitRenegotiationLimitDeprecation =
+  internalUtil.getDeprecationWarningEmitter(
+    'DEP0213',
+    'tls.CLIENT_RENEG_LIMIT and tls.CLIENT_RENEG_WINDOW are deprecated, as ' +
+    'TLS renegotiation is deprecated.',
+  );
+
+function defineRenegotiationLimit(name, key) {
+  // Not enumerable, so that copying the exports does not emit the warning.
+  ObjectDefineProperty(exports, name, {
+    __proto__: null,
+    configurable: true,
+    enumerable: false,
+    get() {
+      emitRenegotiationLimitDeprecation();
+      return tlsCommon.renegotiationLimits[key];
+    },
+    set(value) {
+      emitRenegotiationLimitDeprecation();
+      tlsCommon.renegotiationLimits[key] = value;
+    },
+  });
+}
+defineRenegotiationLimit('CLIENT_RENEG_LIMIT', 'limit');
+defineRenegotiationLimit('CLIENT_RENEG_WINDOW', 'window');

 exports.DEFAULT_CIPHERS = getOptionValue('--tls-cipher-list');

diff --git a/test/common/boringssl.js b/test/common/boringssl.js
index 53d5044e545..321804c5dbb 100644
--- a/test/common/boringssl.js
+++ b/test/common/boringssl.js
@@ -120,6 +120,7 @@ function testRenegotiationUnsupported() {
       port: server.address().port,
       rejectUnauthorized: false,
       maxVersion: 'TLSv1.2',
+      allowRenegotiation: true,
     }, common.mustCall(() => {
       const ok = client.renegotiate({}, common.mustCall((err) => {
         assert.throws(() => { throw err; }, {
diff --git a/test/parallel/test-http2-client-tls-renegotiation.js b/test/parallel/test-http2-client-tls-renegotiation.js
new file mode 100644
index 00000000000..eb91f4bba2f
--- /dev/null
+++ b/test/parallel/test-http2-client-tls-renegotiation.js
@@ -0,0 +1,89 @@
+'use strict';
+
+const common = require('../common');
+if (!common.hasCrypto)
+  common.skip('missing crypto');
+
+const { hasOpenSSL, isBoringSSL } = require('../common/crypto');
+if (isBoringSSL)
+  common.skip('BoringSSL does not support renegotiation');
+
+// An HTTP/2 client refuses a server's request to renegotiate, unless its
+// connection was created with allowRenegotiation: true.
+
+const assert = require('assert');
+const http2 = require('http2');
+const tls = require('tls');
+const fixtures = require('../common/fixtures');
+
+const handshakeFailure = hasOpenSSL(4, 0) ?
+  'ERR_SSL_TLS_ALERT_HANDSHAKE_FAILURE' : hasOpenSSL(3, 2) ?
+    'ERR_SSL_SSL/TLS_ALERT_HANDSHAKE_FAILURE' :
+    'ERR_SSL_SSLV3_ALERT_HANDSHAKE_FAILURE';
+
+const tlsOptions = {
+  ca: fixtures.readKey('ca1-cert.pem'),
+  servername: 'agent1',
+  ALPNProtocols: ['h2'],
+  maxVersion: 'TLSv1.2',
+};
+
+function createServer(onPreface) {
+  return tls.createServer({
+    key: fixtures.readKey('agent1-key.pem'),
+    cert: fixtures.readKey('agent1-cert.pem'),
+    ALPNProtocols: ['h2'],
+    maxVersion: 'TLSv1.2',
+    allowRenegotiation: true,
+  }, common.mustCall((socket) => {
+    // The client's connection preface.
+    socket.once('data', () => onPreface(socket));
+  }));
+}
+
+function testRefused({ createConnection }) {
+  const server = createServer(common.mustCall((socket) => {
+    socket.on('secure', common.mustNotCall('renegotiation completed'));
+    socket.on('error', common.mustCall((err) => {
+      assert.strictEqual(err.code, 'ERR_SSL_NO_RENEGOTIATION');
+      socket.destroy();
+    }));
+    assert.strictEqual(socket.renegotiate({}), true);
+  }));
+
+  server.listen(0, common.mustCall(() => {
+    const { port } = server.address();
+    const options = createConnection ? {
+      createConnection: common.mustCall(() => {
+        return tls.connect({ port, ...tlsOptions });
+      }),
+    } : tlsOptions;
+    const session = http2.connect(`https://localhost:${port}`, options);
+    session.on('error', common.mustCall((err) => {
+      assert.strictEqual(err.code, handshakeFailure);
+    }));
+    session.on('close', common.mustCall(() => server.close()));
+  }));
+}
+
+function testAllowed() {
+  let session;
+  const server = createServer(common.mustCall((socket) => {
+    assert.strictEqual(socket.renegotiate({}, common.mustSucceed(() => {
+      session.destroy();
+      socket.destroy();
+    })), true);
+  }));
+
+  server.listen(0, common.mustCall(() => {
+    session = http2.connect(`https://localhost:${server.address().port}`, {
+      ...tlsOptions,
+      allowRenegotiation: true,
+    });
+    session.on('close', common.mustCall(() => server.close()));
+  }));
+}
+
+testRefused({ createConnection: false });
+testRefused({ createConnection: true });
+testAllowed();
diff --git a/test/parallel/test-https-client-renegotiation-limit.js b/test/parallel/test-https-client-renegotiation-limit.js
index ee83c21c876..be05b32144b 100644
--- a/test/parallel/test-https-client-renegotiation-limit.js
+++ b/test/parallel/test-https-client-renegotiation-limit.js
@@ -57,6 +57,7 @@ function test(next) {
   const options = {
     cert: fixtures.readKey('rsa_cert.crt'),
     key: fixtures.readKey('rsa_private.pem'),
+    allowRenegotiation: true,
   };

   const server = https.createServer(options, common.mustCallAtLeast((req, res) => {
@@ -79,6 +80,7 @@ function test(next) {

     const options = {
       rejectUnauthorized: false,
+      allowRenegotiation: true,
       agent,
     };

diff --git a/test/parallel/test-tls-allow-renegotiation.js b/test/parallel/test-tls-allow-renegotiation.js
index 5292d794b6f..3c2267cc6ff 100644
--- a/test/parallel/test-tls-allow-renegotiation.js
+++ b/test/parallel/test-tls-allow-renegotiation.js
@@ -62,10 +62,10 @@ function assertCannotRenegotiate(socket) {

 // A server that does not allow renegotiation refuses the client's attempt, and
 // the attempt leaves the server's side of the connection as it was.
-function testServerRefuses({ disableRenegotiation }) {
+function testServerRefuses({ allowRenegotiation, disableRenegotiation }) {
   const server = tls.createServer({
     ...serverOptions,
-    allowRenegotiation: false,
+    allowRenegotiation,
   }, common.mustCall((socket) => {
     socket.setTimeout(idleTimeout);
     // Has no effect: the attempt is refused without an error on this side.
@@ -81,7 +81,7 @@ function testServerRefuses({ disableRenegotiation }) {
   }));

   server.listen(0, common.mustCall(() => {
-    connect(server, {}, common.mustCall((client) => {
+    connect(server, { allowRenegotiation: true }, common.mustCall((client) => {
       client.on('error', common.mustCall((err) => {
         assert.strictEqual(err.code, 'ERR_SSL_NO_RENEGOTIATION');
         client.destroy();
@@ -93,8 +93,11 @@ function testServerRefuses({ disableRenegotiation }) {
 }

 // A client that does not allow renegotiation refuses the server's request.
-function testClientRefuses() {
-  const server = tls.createServer(serverOptions, common.mustCall((socket) => {
+function testClientRefuses({ allowRenegotiation }) {
+  const server = tls.createServer({
+    ...serverOptions,
+    allowRenegotiation: true,
+  }, common.mustCall((socket) => {
     socket.on('error', common.mustCall((err) => {
       assert.strictEqual(err.code, 'ERR_SSL_NO_RENEGOTIATION');
       socket.destroy();
@@ -104,7 +107,7 @@ function testClientRefuses() {
   }));

   server.listen(0, common.mustCall(() => {
-    connect(server, { allowRenegotiation: false }, common.mustCall((client) => {
+    connect(server, { allowRenegotiation }, common.mustCall((client) => {
       client.setTimeout(idleTimeout);
       assertCannotRenegotiate(client);
       client.on('secure', common.mustNotCall('renegotiation completed'));
@@ -133,7 +136,10 @@ function testAllowed() {
   }));
 }

-testServerRefuses({ disableRenegotiation: false });
-testServerRefuses({ disableRenegotiation: true });
-testClientRefuses();
+// Renegotiation is refused unless allowRenegotiation is true.
+for (const allowRenegotiation of [undefined, false]) {
+  testServerRefuses({ allowRenegotiation, disableRenegotiation: false });
+  testServerRefuses({ allowRenegotiation, disableRenegotiation: true });
+  testClientRefuses({ allowRenegotiation });
+}
 testAllowed();
diff --git a/test/parallel/test-tls-client-reneg-limit-deprecation.js b/test/parallel/test-tls-client-reneg-limit-deprecation.js
new file mode 100644
index 00000000000..e095e1640ee
--- /dev/null
+++ b/test/parallel/test-tls-client-reneg-limit-deprecation.js
@@ -0,0 +1,37 @@
+'use strict';
+
+const common = require('../common');
+if (!common.hasCrypto)
+  common.skip('missing crypto');
+
+// Reading or writing tls.CLIENT_RENEG_LIMIT or tls.CLIENT_RENEG_WINDOW emits
+// a deprecation warning. Copying the module's exports or importing it as an
+// ES module does not, as the properties are not enumerable.
+
+const assert = require('assert');
+const tls = require('tls');
+
+const unexpectedWarning = common.mustNotCall('warned without access');
+process.on('warning', unexpectedWarning);
+assert.strictEqual(Object.keys(tls).includes('CLIENT_RENEG_LIMIT'), false);
+assert.strictEqual(Object.keys(tls).includes('CLIENT_RENEG_WINDOW'), false);
+
+import('node:tls').then(async (namespace) => {
+  assert.strictEqual(namespace.CLIENT_RENEG_LIMIT, undefined);
+  assert.strictEqual(namespace.default, tls);
+  // Warnings are emitted on a later tick.
+  await new Promise(setImmediate);
+  process.off('warning', unexpectedWarning);
+  common.expectWarning(
+    'DeprecationWarning',
+    'tls.CLIENT_RENEG_LIMIT and tls.CLIENT_RENEG_WINDOW are deprecated, as ' +
+    'TLS renegotiation is deprecated.',
+    'DEP0213');
+
+  assert.strictEqual(tls.CLIENT_RENEG_LIMIT, 3);
+  assert.strictEqual(tls.CLIENT_RENEG_WINDOW, 600);
+  tls.CLIENT_RENEG_LIMIT = 1;
+  tls.CLIENT_RENEG_WINDOW = 10;
+  assert.strictEqual(tls.CLIENT_RENEG_LIMIT, 1);
+  assert.strictEqual(tls.CLIENT_RENEG_WINDOW, 10);
+}).then(common.mustCall());
diff --git a/test/parallel/test-tls-client-renegotiation-13.js b/test/parallel/test-tls-client-renegotiation-13.js
index b69ddd126e5..e3b9603dc1d 100644
--- a/test/parallel/test-tls-client-renegotiation-13.js
+++ b/test/parallel/test-tls-client-renegotiation-13.js
@@ -21,6 +21,7 @@ connect({
   client: {
     ca: server.ca,
     checkServerIdentity: common.mustCall(),
+    allowRenegotiation: true,
   },
   server: {
     key: server.key,
diff --git a/test/parallel/test-tls-client-renegotiation-limit.js b/test/parallel/test-tls-client-renegotiation-limit.js
index b712e6f7d9e..c3344859709 100644
--- a/test/parallel/test-tls-client-renegotiation-limit.js
+++ b/test/parallel/test-tls-client-renegotiation-limit.js
@@ -60,6 +60,7 @@ function test(next) {
   const options = {
     cert: fixtures.readKey('rsa_cert.crt'),
     key: fixtures.readKey('rsa_private.pem'),
+    allowRenegotiation: true,
   };

   const server = tls.createServer(options, common.mustCall((conn) => {
@@ -76,6 +77,7 @@ function test(next) {
       host: server.address().host,
       port: server.address().port,
       rejectUnauthorized: false,
+      allowRenegotiation: true,
     };
     const client = tls.connect(options, spam);

diff --git a/test/parallel/test-tls-coalesce-renegotiation.js b/test/parallel/test-tls-coalesce-renegotiation.js
index 1fd9326a88b..58660a54ff2 100644
--- a/test/parallel/test-tls-coalesce-renegotiation.js
+++ b/test/parallel/test-tls-coalesce-renegotiation.js
@@ -21,6 +21,7 @@ const server = tls.createServer({
   key: fixtures.readKey('agent1-key.pem'),
   cert: fixtures.readKey('agent1-cert.pem'),
   maxVersion: 'TLSv1.2',
+  allowRenegotiation: true,
 }, common.mustCall((socket) => {
   socket.on('data', common.mustCall((data) => {
     assert.deepStrictEqual(data, payload);
@@ -71,6 +72,7 @@ server.listen(0, common.mustCall(() => {
       ca: fixtures.readKey('ca1-cert.pem'),
       servername: 'agent1',
       maxVersion: 'TLSv1.2',
+      allowRenegotiation: true,
     }, common.mustCall(() => {
       holding = true;
       client.write(payload, common.mustCall(() => {
diff --git a/test/parallel/test-tls-disable-renegotiation.js b/test/parallel/test-tls-disable-renegotiation.js
index 1934becc2a6..116c7f2b270 100644
--- a/test/parallel/test-tls-disable-renegotiation.js
+++ b/test/parallel/test-tls-disable-renegotiation.js
@@ -23,6 +23,7 @@ tls.DEFAULT_MAX_VERSION = 'TLSv1.2';
 const options = {
   key: fixtures.readKey('agent1-key.pem'),
   cert: fixtures.readKey('agent1-cert.pem'),
+  allowRenegotiation: true,
 };

 const server = tls.Server(options, common.mustCall((socket) => {
@@ -53,6 +54,7 @@ server.listen(0, common.mustCall(() => {
   const port = server.address().port;
   const options = {
     rejectUnauthorized: false,
+    allowRenegotiation: true,
     port
   };
   const client = tls.connect(options, common.mustCall(() => {
diff --git a/test/parallel/test-tls-renegotiate-servername.js b/test/parallel/test-tls-renegotiate-servername.js
index b7ea9416650..25c552a7c9f 100644
--- a/test/parallel/test-tls-renegotiate-servername.js
+++ b/test/parallel/test-tls-renegotiate-servername.js
@@ -169,6 +169,7 @@ const server = tls.createServer({
   // Offering only this group makes the server answer a TLS 1.3 client, whose
   // first key share is for a different curve, with a HelloRetryRequest.
   ecdhCurve: 'P-521',
+  allowRenegotiation: true,
 }, (socket) => {
   socket.on('error', () => {});
   socket.resume();
diff --git a/test/parallel/test-tls-renegotiation-pending-deprecation.js b/test/parallel/test-tls-renegotiation-deprecation.js
similarity index 63%
rename from test/parallel/test-tls-renegotiation-pending-deprecation.js
rename to test/parallel/test-tls-renegotiation-deprecation.js
index f8f692299cd..78a836f2b2a 100644
--- a/test/parallel/test-tls-renegotiation-pending-deprecation.js
+++ b/test/parallel/test-tls-renegotiation-deprecation.js
@@ -8,8 +8,8 @@ const { isBoringSSL } = require('../common/crypto');
 if (isBoringSSL)
   common.skip('BoringSSL does not support renegotiation');

-// With --pending-deprecation, renegotiation emits a deprecation warning unless
-// it is a client that set allowRenegotiation: true accepting a server's request.
+// Renegotiation emits a deprecation warning, unless it is a client that set
+// allowRenegotiation: true accepting a server's request.

 const assert = require('assert');
 const { fork } = require('child_process');
@@ -30,16 +30,7 @@ if (process.argv[2] === 'child') {
     JSON.parse(process.argv[3]);

   if (role === 'server') {
-    const server = tls.createServer({
-      ...serverOptions,
-      allowRenegotiation,
-    }, common.mustCall((socket) => {
-      socket.resume();
-      socket.on('close', common.mustCall(() => server.close()));
-    }));
-    server.listen(0, common.mustCall(() => {
-      process.send({ port: server.address().port });
-    }));
+    tls.createServer({ ...serverOptions, allowRenegotiation });
   } else {
     const client = tls.connect({
       port,
@@ -56,7 +47,6 @@ if (process.argv[2] === 'child') {

 function start(options, warns) {
   const child = fork(__filename, ['child', JSON.stringify(options)], {
-    execArgv: ['--pending-deprecation'],
     stdio: ['ignore', 'inherit', 'pipe', 'ipc'],
   });
   let stderr = '';
@@ -69,24 +59,13 @@ function start(options, warns) {
       warns,
       stderr);
   }));
-  return child;
-}
-
-function testServer(options, warns) {
-  const child = start({ role: 'server', ...options }, warns);
-  child.on('message', common.mustCall(({ port }) => {
-    const client = tls.connect({
-      port,
-      rejectUnauthorized: false,
-    }, common.mustCall(() => {
-      client.renegotiate({}, common.mustSucceed(() => client.end()));
-    }));
-    client.resume();
-  }));
 }

 function testClient(options, warns) {
-  const server = tls.createServer(serverOptions, common.mustCall((socket) => {
+  const server = tls.createServer({
+    ...serverOptions,
+    allowRenegotiation: true,
+  }, common.mustCall((socket) => {
     socket.resume();
     socket.on('close', common.mustCall(() => server.close()));
     if (!options.initiate)
@@ -97,10 +76,10 @@ function testClient(options, warns) {
   }));
 }

-// A server completing a renegotiation, whether or not it set the option.
-testServer({ allowRenegotiation: true }, true);
+// A server that allows renegotiation.
+start({ role: 'server', allowRenegotiation: true }, true);
+start({ role: 'server' }, false);
 // Any call to renegotiate().
 testClient({ allowRenegotiation: true, initiate: true }, true);
-// A client accepting the server's request, unless it set the option.
-testClient({ initiate: false }, true);
+// A client accepting the server's request.
 testClient({ allowRenegotiation: true, initiate: false }, false);
diff --git a/test/parallel/test-tls-server-verify.js b/test/parallel/test-tls-server-verify.js
index c7487f593eb..744ffd4a616 100644
--- a/test/parallel/test-tls-server-verify.js
+++ b/test/parallel/test-tls-server-verify.js
@@ -279,6 +279,7 @@ function runTest(port, testIndex) {
         SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION;
     // Renegotiation as a protocol feature was dropped after TLS1.2.
     serverOptions.maxVersion = 'TLSv1.2';
+    serverOptions.allowRenegotiation = true;
   }

   let renegotiated = false;
diff --git a/test/parallel/test-tls-sni-context-renegotiate.js b/test/parallel/test-tls-sni-context-renegotiate.js
index 756a9ad1e6e..fe0fec93c7d 100644
--- a/test/parallel/test-tls-sni-context-renegotiate.js
+++ b/test/parallel/test-tls-sni-context-renegotiate.js
@@ -22,6 +22,8 @@ const server = tls.createServer({
   // Offering only this group makes the server answer a TLS 1.3 client whose
   // first key share is for another one with a HelloRetryRequest.
   ecdhCurve: 'P-521',
+  // BoringSSL servers don't support renegotiation.
+  allowRenegotiation: !isBoringSSL,
 }, common.mustCall((socket) => {
   assert.strictEqual(socket.servername, 'certless.example');
   socket.resume();
@@ -36,6 +38,7 @@ function connect(maxVersion) {
       rejectUnauthorized: false,
       maxVersion,
       ecdhCurve: 'P-256:P-521',
+      allowRenegotiation: true,
     }, () => resolve(socket));
   });
 }
@@ -44,7 +47,6 @@ server.listen(0, common.mustCall(async () => {
   const retried = await connect('TLSv1.3');
   retried.end();

-  // BoringSSL servers don't support renegotiation.
   if (!isBoringSSL) {
     const renegotiating = await connect('TLSv1.2');
     await new Promise((resolve) => {