Skip to content
This repository has been archived by the owner on Jul 24, 2019. It is now read-only.

Make sure the fist item in the ca array actually contains a certificate #457

Merged
merged 1 commit into from
Jan 29, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions install.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ function getRequestOptions() {
try {
ca = fs.readFileSync(process.env.npm_config_cafile, {encoding: 'utf8'})
.split(/\n(?=-----BEGIN CERTIFICATE-----)/g)

// Comments at the beginning of the file result in the first
// item not containing a certificate - in this case the
// download will fail
if (ca.length > 0 && !/-----BEGIN CERTIFICATE-----/.test(ca[0])) {
ca.shift()
}

} catch (e) {
console.error('Could not read cafile', process.env.npm_config_cafile, e)
}
Expand Down