From 56425abccb46741dbb0d5ea98148f03a35fce849 Mon Sep 17 00:00:00 2001 From: Christof Marti Date: Sat, 9 Mar 2019 21:19:21 +0000 Subject: [PATCH] CentOS / Fedora path to CA certificates (#52880) --- .../services/extensions/node/proxyResolver.ts | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/services/extensions/node/proxyResolver.ts b/src/vs/workbench/services/extensions/node/proxyResolver.ts index c31f7a0c65ad2..32a6306198a9e 100644 --- a/src/vs/workbench/services/extensions/node/proxyResolver.ts +++ b/src/vs/workbench/services/extensions/node/proxyResolver.ts @@ -488,15 +488,29 @@ async function readMacCaCertificates() { }; } +const linuxCaCertificatePaths = [ + '/etc/ssl/certs/ca-certificates.crt', + '/etc/ssl/certs/ca-bundle.crt', +]; + async function readLinuxCaCertificates() { - const content = await promisify(fs.readFile)('/etc/ssl/certs/ca-certificates.crt', { encoding: 'utf8' }); - const seen = {}; - const certs = content.split(/(?=-----BEGIN CERTIFICATE-----)/g) - .filter(pem => !!pem.length && !seen[pem] && (seen[pem] = true)); - return { - certs, - append: false - }; + for (const certPath of linuxCaCertificatePaths) { + try { + const content = await promisify(fs.readFile)(certPath, { encoding: 'utf8' }); + const seen = {}; + const certs = content.split(/(?=-----BEGIN CERTIFICATE-----)/g) + .filter(pem => !!pem.length && !seen[pem] && (seen[pem] = true)); + return { + certs, + append: false + }; + } catch (err) { + if (err.code !== 'ENOENT') { + throw err; + } + } + } + return undefined; } function derToPem(blob) {