ca certs function updates (#5555)

This commit is contained in:
lohit
2025-09-12 21:49:49 +05:30
committed by GitHub
parent dbfbde43cf
commit 9fc885839f
3 changed files with 7 additions and 7 deletions

View File

@@ -155,7 +155,7 @@ const runSingleRequest = async function (
httpsAgentRequestFields['rejectUnauthorized'] = false;
} else {
const caCertFilePath = options['cacert'];
let caCertificatesData = await getCACertificates({ caCertFilePath, shouldKeepDefaultCerts: !options['ignoreTruststore'] });
let caCertificatesData = getCACertificates({ caCertFilePath, shouldKeepDefaultCerts: !options['ignoreTruststore'] });
let caCertificates = caCertificatesData.caCertificates;
httpsAgentRequestFields['ca'] = caCertificates || [];
}

View File

@@ -27,7 +27,7 @@ const getCertsAndProxyConfig = async ({
}
let caCertFilePath = preferencesUtil.shouldUseCustomCaCertificate() && preferencesUtil.getCustomCaCertificateFilePath();
let caCertificatesData = await getCACertificates({
let caCertificatesData = getCACertificates({
caCertFilePath,
shouldKeepDefaultCerts: preferencesUtil.shouldKeepDefaultCaCertificates()
});

View File

@@ -18,7 +18,7 @@ type T_CACertificatesResult = {
let systemCertsCache: string[] | undefined;
async function getSystemCerts(): Promise<string[]> {
function getSystemCerts(): string[] {
if (systemCertsCache) return systemCertsCache;
try {
@@ -87,10 +87,10 @@ function getNodeExtraCACerts(): string[] {
*
* @param caCertFilePath - path to custom CA certificate file
* @param shouldKeepDefaultCerts - whether to keep default CA certificates
* @returns {Promise<T_CACertificatesResult>} - CA certificates and their count
* @returns {T_CACertificatesResult} - CA certificates and their count
*/
const getCACertificates = async ({ caCertFilePath, shouldKeepDefaultCerts = true }: T_CACertificatesOptions): Promise<T_CACertificatesResult> => {
const getCACertificates = ({ caCertFilePath, shouldKeepDefaultCerts = true }: T_CACertificatesOptions): T_CACertificatesResult => {
try {
let caCertificates = '';
let caCertificatesCount = {
@@ -126,7 +126,7 @@ const getCACertificates = async ({ caCertFilePath, shouldKeepDefaultCerts = true
if (shouldKeepDefaultCerts) {
// get system certs
systemCerts = await getSystemCerts();
systemCerts = getSystemCerts();
caCertificatesCount.system = systemCerts.length;
// get root certs
@@ -135,7 +135,7 @@ const getCACertificates = async ({ caCertFilePath, shouldKeepDefaultCerts = true
}
} else {
// get system certs
systemCerts = await getSystemCerts();
systemCerts = getSystemCerts();
caCertificatesCount.system = systemCerts.length;
// get root certs