mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
Similar to how NODE_USE_ENV_PROXY complements --use-env-proxy, this complements --use-system-ca. This will allow the setting to be applied to workers individually in the future. PR-URL: https://github.com/nodejs/node/pull/59276 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ethan Arrowood <ethan@arrowood.dev> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
30 lines
930 B
JavaScript
30 lines
930 B
JavaScript
'use strict';
|
|
// This tests that NODE_USE_SYSTEM_CA environment variable works the same
|
|
// as --use-system-ca flag by comparing certificate counts.
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto) common.skip('missing crypto');
|
|
|
|
const tls = require('tls');
|
|
const { spawnSyncAndExitWithoutError } = require('../common/child_process');
|
|
|
|
const systemCerts = tls.getCACertificates('system');
|
|
if (systemCerts.length === 0) {
|
|
common.skip('no system certificates available');
|
|
}
|
|
|
|
const { child: { stdout: expectedLength } } = spawnSyncAndExitWithoutError(process.execPath, [
|
|
'--use-system-ca',
|
|
'-p',
|
|
`tls.getCACertificates('default').length`,
|
|
], {
|
|
env: { ...process.env, NODE_USE_SYSTEM_CA: '0' },
|
|
});
|
|
|
|
spawnSyncAndExitWithoutError(process.execPath, [
|
|
'-p',
|
|
`assert.strictEqual(tls.getCACertificates('default').length, ${expectedLength.toString()})`,
|
|
], {
|
|
env: { ...process.env, NODE_USE_SYSTEM_CA: '1' },
|
|
});
|