Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Honor npm configuration for CA bundles #243

Merged
merged 1 commit into from
Oct 26, 2016
Merged

Honor npm configuration for CA bundles #243

merged 1 commit into from
Oct 26, 2016

Conversation

heikkipora
Copy link
Contributor

Pass ‘ca’ and ‘cafile’ values from npm config options to request() when downloading binaries to honor a user-specified SSL CA. Allows using node-pre-gyp on environments with custom CAs.

@heikkipora
Copy link
Contributor Author

heikkipora commented Oct 23, 2016

Sigh.. retire.js is broken at the moment so "npm install" fails for node-pre-gyp. See RetireJS/retire.js#141

@heikkipora
Copy link
Contributor Author

Retire.js also incorrectly flags cli-1.0.1 as vulnerable, so posted a PR for that as well to get your build to pass 😄 RetireJS/retire.js#143

@heikkipora heikkipora closed this Oct 24, 2016
@heikkipora heikkipora reopened this Oct 24, 2016
@springmeyer
Copy link
Contributor

Thank you for the contribution @heikkipora. I have a few questions:

  1. This looks different than what node-gyp does (nodejs/node-gyp@8c4b0ff). I think the node-gyp impl looks more robust. Can you take a look at reimplementing this based on node-gyp's method? I think that gyp.opts.cafile will be == to opts.cafile in node-pre-gyp.

  2. We'll need tests for this functionality. Can you think of a way to test this in the unit tests?

@heikkipora
Copy link
Contributor Author

  1. I originally took a look at that impl and thought that readCAFile() is practically just waste as people don't generally store random stuff in their PEM files 😄 - and reading a PEM directly without parsing their content is common practice (see e.g. https://github.com/request/request#tlsssl-protocol).

All of gyp.opts.* are currently not merged to opts.* so opts.cafile won't be available automatically. I modified my commit so that gyp.opts.ca and gyp.opts.cafile are passed to download() via opts - which seems a bit cleaner approach to accessing them from process.env

  1. I cannot figure out any meaningful way to test this with a unit test. On the other hand it's not very critical nor complex functionality so it may be OK to let it live without one (writing a complicated test setup just for this doesn't have a good ROI in my opinion).

What do you think ?

@springmeyer
Copy link
Contributor

Looks great @heikkipora, thank you for that revision. I notice that something is broken with appveyor and it appears to be in old tests that are no longer maintained. I just removed those in 35b10c3. Would you mind rebasing against master and then we'll see if your commit passes on both travis and appveyor okay?

…en downloading binaries to honor a user-specified SSL CA.
@heikkipora
Copy link
Contributor Author

The PR has now been rebased against master. However, there's still one (rather ironic) failure on the AppVeyor node 4.6.1/x86 environment where node-gyp tries to read a PEM CA file with undefined name 😃 . Do you have any clue why it does that or how to make that work?

@springmeyer
Copy link
Contributor

@heikkipora - thanks for the rebase. About to head to sleep here (PST) but will plan to merge in the morning. As far as that bizarre appveyor test - no, mysterious (#209) and unrelated to your PR (though I hoped your PR might solve).

@heikkipora
Copy link
Contributor Author

Ok!

@springmeyer springmeyer merged commit 9c0e9ea into mapbox:master Oct 26, 2016
@springmeyer
Copy link
Contributor

Merged, will be included in v0.6.32. Thanks @heikkipora!

@Mazza-Chen Mazza-Chen mentioned this pull request Nov 30, 2016
hyj1991 pushed a commit to X-Profiler/node-pre-gyp that referenced this pull request Jun 16, 2023
Honor npm configuration for CA bundles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants