Open
Description
Version
18.x
Platform
Ubuntu, Mac
Subsystem
No response
What steps will reproduce the bug?
addCACert()
has bottleneck when HTTPS endpoint is called with https.agent.ca
option using https
, when we switch to using NODE_EXTRA_CA_CERTS
environment variable, we do not see addCACert()
bottleneck.
With agent.ca
options pointing to CA certs
const https = require('https');
const fs = require('fs');
// Read the CA certificate file (replace 'ca.pem' with your actual CA certificate file path)
const caCert = fs.readFileSync('ca.pem');
// Create an agent with the CA certificate
const agent = new https.Agent({
ca: caCert
});
function callHttpsService(url) {
https.get(url, { agent: agent }, (res) => {
let data = '';
// A chunk of data has been received.
res.on('data', (chunk) => {
data += chunk;
});
// The whole response has been received. Print out the result.
res.on('end', () => {
console.log(data);
});
}).on("error", (err) => {
console.log("Error: " + err.message);
});
}
callHttpsService('https://example.com');

With NODE_EXTRA_CA_CERTS
env variable pointing to CA certs
export NODE_EXTRA_CA_CERTS=/path/to/cert.pem && node index.js
// index.js
const https = require('https');
function callHttpsService(url) {
https.get(url, { agent: agent }, (res) => {
let data = '';
// A chunk of data has been received.
res.on('data', (chunk) => {
data += chunk;
});
// The whole response has been received. Print out the result.
res.on('end', () => {
console.log(data);
});
}).on("error", (err) => {
console.log("Error: " + err.message);
});
}
callHttpsService('https://example.com');

How often does it reproduce? Is there a required condition?
This is introduced in Node 16.x and seen in Node 18.x & Node 20.x. For every request.
What is the expected behavior? Why is that the expected behavior?

What do you see instead?

Additional information
No response