diff --git a/README.md b/README.md index c9a7e9e0eb0a22..375de75dd97540 100644 --- a/README.md +++ b/README.md @@ -790,7 +790,7 @@ responding to new issues. Primary GPG keys for Node.js Releasers (some Releasers sign with subkeys): * **Antoine du Hamel** <> - `C0D6248439F1D5604AAFFB4021D900FFDB233756` + `5BE8A3F6C8A5C01D106C0AD820B1A390B168D356` * **Juan José Arboleda** <> `DD792F5973C6DE52C432CBDAC77ABFA00DDBF2B7` * **Marco Ippolito** <> @@ -810,7 +810,7 @@ To import the full set of trusted release keys (including subkeys possibly used to sign releases): ```bash -gpg --keyserver hkps://keys.openpgp.org --recv-keys C0D6248439F1D5604AAFFB4021D900FFDB233756 # Antoine du Hamel +gpg --keyserver hkps://keys.openpgp.org --recv-keys 5BE8A3F6C8A5C01D106C0AD820B1A390B168D356 # Antoine du Hamel gpg --keyserver hkps://keys.openpgp.org --recv-keys DD792F5973C6DE52C432CBDAC77ABFA00DDBF2B7 # Juan José Arboleda gpg --keyserver hkps://keys.openpgp.org --recv-keys CC68F5A3106FF448322E48ED27F5E38D5B0A215F # Marco Ippolito gpg --keyserver hkps://keys.openpgp.org --recv-keys 8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 # Michaël Zasso @@ -827,6 +827,8 @@ verify a downloaded file. Other keys used to sign some previous releases +* **Antoine du Hamel** <> + `C0D6248439F1D5604AAFFB4021D900FFDB233756` * **Beth Griggs** <> `4ED778F539E3634C779C87C6D7062848A1AB005C` * **Bryan English** <> diff --git a/doc/api/tls.md b/doc/api/tls.md index 5fde522dc9ae31..7be5ee7fb29a56 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -2260,6 +2260,54 @@ openssl pkcs12 -certpbe AES-256-CBC -export -out client-cert.pem \ The server can be tested by connecting to it using the example client from [`tls.connect()`][]. +## `tls.setDefaultCACertificates(certs)` + + + +* `certs` {string\[]|ArrayBufferView\[]} An array of CA certificates in PEM format. + +Sets the default CA certificates used by Node.js TLS clients. If the provided +certificates are parsed successfully, they will become the default CA +certificate list returned by [`tls.getCACertificates()`][] and used +by subsequent TLS connections that don't specify their own CA certificates. +The certificates will be deduplicated before being set as the default. + +This function only affects the current Node.js thread. Previous +sessions cached by the HTTPS agent won't be affected by this change, so +this method should be called before any unwanted cachable TLS connections are +made. + +To use system CA certificates as the default: + +```cjs +const tls = require('node:tls'); +tls.setDefaultCACertificates(tls.getCACertificates('system')); +``` + +```mjs +import tls from 'node:tls'; +tls.setDefaultCACertificates(tls.getCACertificates('system')); +``` + +This function completely replaces the default CA certificate list. To add additional +certificates to the existing defaults, get the current certificates and append to them: + +```cjs +const tls = require('node:tls'); +const currentCerts = tls.getCACertificates('default'); +const additionalCerts = ['-----BEGIN CERTIFICATE-----\n...']; +tls.setDefaultCACertificates([...currentCerts, ...additionalCerts]); +``` + +```mjs +import tls from 'node:tls'; +const currentCerts = tls.getCACertificates('default'); +const additionalCerts = ['-----BEGIN CERTIFICATE-----\n...']; +tls.setDefaultCACertificates([...currentCerts, ...additionalCerts]); +``` + ## `tls.getCACertificates([type])`