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

feat: respect NODE_TLS_REJECT_UNAUTHORIZED #146

Closed
wants to merge 3 commits into from

Conversation

pbeast
Copy link

@pbeast pbeast commented Apr 30, 2024

As described in #61, setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable doesn't change the library's behavior. This is required in different scenarios, such as testing, self-signed certificates, ZScaler, etc.

This PR adds a check for the process's environment variable NODE_TLS_REJECT_UNAUTHORIZED, and if it is set to 0 sets rejectUnauthorized to false.

if (process.env['NODE_TLS_REJECT_UNAUTHORIZED'] == '0') {
  console.warn("-----------------------[ minipass-fetch ]-----------------------------");
  console.warn("- NODE_TLS_REJECT_UNAUTHORIZED is set to 0. This is not recommended. -");
  console.warn("----------------------------------------------------------------------");

  options.agent.options.rejectUnauthorized = false;
}

References

Fixes #61
Closes #61

@pbeast pbeast requested a review from a team as a code owner April 30, 2024 17:28
lib/index.js Outdated Show resolved Hide resolved
@wraithgar
Copy link
Member

This will need a test to cover the if statement.

@wraithgar
Copy link
Member

npm has a strict-ssl flag, does that not work for this use case?

@pbeast
Copy link
Author

pbeast commented Apr 30, 2024

npm has a strict-ssl flag, does that not work for this use case?

Nope 😔 Unfortunately, this flag doesn't solve the problem.

@pbeast
Copy link
Author

pbeast commented Apr 30, 2024

I will add the test and fix the logging.
Please keep the PR open.

direct console logging removed
@pbeast
Copy link
Author

pbeast commented May 1, 2024

Hi @wraithgar , I made the requested changes. Can you please check?

@reggi
Copy link
Contributor

reggi commented May 21, 2024

hey @pbeast thanks for digging into this but I've added tests here #149 that show this already works in minipass-fetch, I believe that node-gyp needs to pass the strictSSL option to make-fetch-happen. I'm gonna close this out and the corresponding issue.

@reggi reggi closed this May 21, 2024
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.

[BUG] Not Respecting NODE_TLS_REJECT_UNAUTHORIZED = 0
3 participants