Skip to content

Commit

Permalink
CentOS / Fedora path to CA certificates (#52880)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrmarti committed Mar 9, 2019
1 parent 6cc7eea commit 56425ab
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/vs/workbench/services/extensions/node/proxyResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 56425ab

Please sign in to comment.