mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
442610fa51
A fix to tls.rootCertificates to have it correctly return the process' current root certificates resulted in non-deterministic behavior when Node.js is configured to use an OpenSSL system or file-based certificate store. The safest action is to revert the change and change the specification for tls.rootCertificates to state that it only returns the bundled certificates instead of the current ones. Fixes: https://github.com/nodejs/node/issues/32229 Refs: https://github.com/nodejs/node/issues/32074 PR-URL: https://github.com/nodejs/node/pull/33313 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
32 lines
947 B
JavaScript
32 lines
947 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
if (!common.hasCrypto) common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const tls = require('tls');
|
|
|
|
assert(Array.isArray(tls.rootCertificates));
|
|
assert(tls.rootCertificates.length > 0);
|
|
|
|
// Getter should return the same object.
|
|
assert.strictEqual(tls.rootCertificates, tls.rootCertificates);
|
|
|
|
// Array is immutable...
|
|
assert.throws(() => tls.rootCertificates[0] = 0, /TypeError/);
|
|
assert.throws(() => tls.rootCertificates.sort(), /TypeError/);
|
|
|
|
// ...and so is the property.
|
|
assert.throws(() => tls.rootCertificates = 0, /TypeError/);
|
|
|
|
// Does not contain duplicates.
|
|
assert.strictEqual(tls.rootCertificates.length,
|
|
new Set(tls.rootCertificates).size);
|
|
|
|
assert(tls.rootCertificates.every((s) => {
|
|
return s.startsWith('-----BEGIN CERTIFICATE-----\n');
|
|
}));
|
|
|
|
assert(tls.rootCertificates.every((s) => {
|
|
return s.endsWith('\n-----END CERTIFICATE-----');
|
|
}));
|