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

Commit

Permalink
Make sure the fist item in the ca array actually contains a certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
Chad Killingsworth committed Jan 29, 2016
1 parent 121f901 commit d5b2d84
Showing 1 changed file with 8 additions and 0 deletions.
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

0 comments on commit d5b2d84

Please sign in to comment.