node/test/fixtures/list-certs.js
Joyee Cheung 6432765a9c
src: fix off-thread cert loading in bundled cert mode
https://redirect.github.com/nodejs/node/pull/59856 had an typo/mistake
in the skip conditions so that it is skipping when --use-openssl-ca
or --openssl-system-ca-path (configure time) are NOT used, even
though they should be skipped only when those ARE used (which is
not the default for default builds). This change fixes that so
that the perf numbers in that PR is true for the default build.

PR-URL: https://github.com/nodejs/node/pull/60764
Reviewed-By: Aditi Singh <aditisingh1400@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2025-12-02 09:51:06 +00:00

19 lines
766 B
JavaScript

const assert = require('assert');
const EXPECTED_CERTS_PATH = process.env.EXPECTED_CERTS_PATH;
let expectedCerts = [];
if (EXPECTED_CERTS_PATH) {
const fs = require('fs');
const file = fs.readFileSync(EXPECTED_CERTS_PATH, 'utf-8');
const expectedCerts = file.split('-----END CERTIFICATE-----\n')
.filter(line => line.trim() !== '')
.map(line => line + '-----END CERTIFICATE-----\n');
}
const tls = require('tls');
const { includesCert, extractMetadata } = require('../common/tls');
const CERTS_TYPE = process.env.CERTS_TYPE || 'default';
const actualCerts = tls.getCACertificates(CERTS_TYPE);
for (const cert of expectedCerts) {
assert(includesCert(actualCerts, cert), 'Expected certificate not found: ' + JSON.stringify(extractMetadata(cert)));
}