-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
crypto: add tls.setDefaultCACertificates() #58822
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
base: main
Are you sure you want to change the base?
Conversation
Review requested:
|
The
notable-change
Please suggest a text for the release notes if you'd like to include a more detailed summary, then proceed to update the PR description with the text or a link to the notable change suggested text comment. Otherwise, the commit will be placed in the Other Notable Changes section. |
This comment was marked as outdated.
This comment was marked as outdated.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #58822 +/- ##
========================================
Coverage 90.06% 90.07%
========================================
Files 645 645
Lines 189130 189283 +153
Branches 37094 37128 +34
========================================
+ Hits 170339 170494 +155
+ Misses 11511 11476 -35
- Partials 7280 7313 +33
🚀 New features to boost your workflow:
|
As indicated in comments, I generally don't think this is a good thing to add but don't feel strongly enough about it to block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Marking it blocked until I investigated whether the (I gave it some thoughts and I wondered whether allowing more than just system certificates is a bit icky, but then I remembered again user land is already capable of monkey patching the tls methods to always add in random certificates and has been doing so anyways so not really a big deal ¯\(ツ)/¯ so far it looks implementable but I need to double check cleanup is done correctly). |
Also noticed another benefit of |
This API allows dynamically configuring CA certificates that will be used by the Node.js TLS clients by default. Once called, the provided certificates will become the default CA certificate list returned by `tls.getCACertificates('default')` and used by TLS connections that don't specify their own CA certificates. This function only affects the current Node.js thread.
51ddd68
to
bbd77e1
Compare
@pimterry @mcollina @jasnell Updated to the new API design |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it! This looks great to me, and super useful 👍 👍 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment was marked as outdated.
This comment was marked as outdated.
Fixed test skipping logic for withoutssl builds. @pimterry @Ethan-Arrowood can you take a look again? Thanks! |
This comment was marked as outdated.
This comment was marked as outdated.
202be4b
to
8d040a8
Compare
This API allows dynamically configuring CA certificates that
will be used by the Node.js TLS clients by default.
Once called, the provided certificates will become the default CA
certificate list returned by
tls.getCACertificates('default')
andused by TLS connections that don't specify their own CA certificates.
This function only affects the current Node.js thread.
Background
This API serves two at least use cases:
rejectUnauthorized: false
or having to spawn child processes which can affect the validity or debuggability of the test.The functionality provided by this API already has been possible via monkey patching tls or the global HTTPS agents, and the user land has already been doing it - for example, see syswide-cas, win-ca, ssl-root-cas. I am fairly certain when none of the existing options work there are applications/packages that would just go a nuclear route and use
rejectUnauthorized: false
in the monkey-patched option bag to avoid whatever woes they have, considering how often it shows up on the Internet and on even public GitHub. Providing a proper API to allow using custom certificates dynamically would overall make the practice less brittle in the ecosystem.