use node:tls library for ca certs (#5552)

This commit is contained in:
lohit
2025-09-12 20:29:28 +05:30
committed by GitHub
parent 2b6da56c3c
commit 1aa4e27ab5
4 changed files with 6 additions and 80 deletions

View File

@@ -1,5 +1,4 @@
import { systemCertsAsync, Options as SystemCAOptions } from 'system-ca';
import { rootCertificates } from 'node:tls';
import * as tls from 'node:tls';
import * as fs from 'node:fs';
type T_CACertificatesOptions = {
@@ -19,11 +18,11 @@ type T_CACertificatesResult = {
let systemCertsCache: string[] | undefined;
async function getSystemCerts(systemCAOpts: SystemCAOptions = {}): Promise<string[]> {
async function getSystemCerts(): Promise<string[]> {
if (systemCertsCache) return systemCertsCache;
try {
systemCertsCache = await systemCertsAsync(systemCAOpts);
systemCertsCache = tls.getCACertificates('system');
return systemCertsCache;
} catch (error) {
@@ -131,7 +130,7 @@ const getCACertificates = async ({ caCertFilePath, shouldKeepDefaultCerts = true
caCertificatesCount.system = systemCerts.length;
// get root certs
rootCerts = [...rootCertificates];
rootCerts = [...tls.rootCertificates];
caCertificatesCount.root = rootCerts.length;
}
} else {
@@ -140,7 +139,7 @@ const getCACertificates = async ({ caCertFilePath, shouldKeepDefaultCerts = true
caCertificatesCount.system = systemCerts.length;
// get root certs
rootCerts = [...rootCertificates];
rootCerts = [...tls.rootCertificates];
caCertificatesCount.root = rootCerts.length;
}