tls: use options in getCACertificates() with X509Certificate - #59349
tls: use options in getCACertificates() with X509Certificate#59349haramj wants to merge 8 commits into
Conversation
|
Review requested:
|
| trusted store. | ||
| * When [`NODE_EXTRA_CA_CERTS`][] is used, this would also include certificates loaded from the specified | ||
| file. | ||
|
|
There was a problem hiding this comment.
It seems the white spaces are still there? Can you remove them?
There was a problem hiding this comment.
Okay. I'll remove the white space
There was a problem hiding this comment.
@joyeecheung Removing that white space will cause a format error in the document..
|
@jasnell Thank you very much for the thorough and detailed reviews. Additionally, |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #59349 +/- ##
==========================================
- Coverage 90.19% 90.17% -0.03%
==========================================
Files 771 771
Lines 264628 265482 +854
Branches 50237 50463 +226
==========================================
+ Hits 238683 239396 +713
- Misses 16953 17034 +81
- Partials 8992 9052 +60
🚀 New features to boost your workflow:
|
|
The CI is failing due to a missing documentation anchor: |
2e19981 to
d978079
Compare
|
Hi, feedback has been addressed. |
|
If you have some time, could you please review this? @nodejs/net, @joyeecheung |
jasnell
left a comment
There was a problem hiding this comment.
LGTM! Great job. Let's ask @joyeecheung to also take a look since it was her TODO :-)
Thank you so much for the review and the LGTM! I really appreciate your time. During my final testing, I discovered an unexpected failure related to caching, and also found a minor inconsistency with the documentation. I would like to push a fix for those before the PR is ready to merge. I'll push the updated changes shortly. |
|
@jasnell @joyeecheung So I added the caching logic, but now other tests are failing. |
|
I've successfully implemented support for new formats by clearly separating the logic for object input while maintaining the existing function's behavior. All tests have passed, and I believe the PR is ready for review. Thank you. |
|
@joyeecheung I've applied the feedback. Could you take a look? |
|
Could you please take a look at this when you have a moment? Thanks! @joyeecheung |
e2879a5 to
e787797
Compare
|
Hi @joyeecheung, I've refactored getCACertificates() to follow a clean, linear flow: Normalize options to handle both string and object inputs. Single retrieval using getCACertificatesAsStrings(). Process results based on the requested format. This eliminates redundant calls and preserves caching for the default format. I also updated the tests to strictly verify data integrity using tlsCommon.assertEqualCerts() |
|
This pull request has been marked as stale due to 90 days of inactivity. |
990715e to
b628c60
Compare
b628c60 to
a38fa24
Compare
|
Hi @jasnell @joyeecheung @daeyeon, I've rebased this PR onto the latest Would you mind taking another look when you have a moment? Thanks! |
Signed-off-by: haramjeong <04harams77@gmail.com>
a38fa24 to
b032b37
Compare
|
Hi @jasnell, I've rebased this PR onto the latest main and all CI checks pass. Could you please take another look when you have a moment? The previous approval became stale after the code changes. Thanks! |
- Change API to use two separate arguments: getCACertificates(type, options) instead of polymorphic single options argument, per reviewer feedback - Remove unnecessary '= undefined' from function parameter - Restore removed test case for default type caching - Update documentation and tests to match new signature Signed-off-by: haramjeong <04harams77@gmail.com> Assisted-by: opencode/mimo-v2.5-free
Address markdown lint failure and review feedback: - Add blank line between parameter entries to satisfy remark-lint rules - Remove extra blank lines between type description list items to match original formatting style
Add assertions to bundled, default, and system test files to verify that the options object form with format: 'pem' returns the same results as the string argument form, ensuring backward compatibility.
|
@jasnell Thanks for the review! I've addressed the feedback in the latest commits, including the API signature, tests, and documentation updates. I've also added coverage to verify that the options form remains consistent with the string form. Thanks again! |
The X509Certificate class imported from require('crypto') in lib/tls.js
does not work correctly during bootstrap - it returns a broken object
instead of proper X509Certificate instances. Use InternalX509Certificate
from require('internal/crypto/x509') instead, which is the pattern used
by other internal modules like lib/internal/tls/wrap.js.
Signed-off-by: opencode <opencode@opencode.ai>
Assisted-by: opencode <opencode>
The X509Certificate class imported from require('crypto') in lib/tls.js
does not work correctly during bootstrap - it returns a broken object
instead of proper X509Certificate instances. Use InternalX509Certificate
from require('internal/crypto/x509') instead, which is the pattern used
by other internal modules like lib/internal/tls/wrap.js.
InternalX509Certificate expects a Buffer (DER-encoded) rather than a
PEM string, so wrap the PEM string with Buffer.from() to match the
pattern used by the user-facing X509Certificate constructor.
Signed-off-by: opencode <opencode@opencode.ai>
Assisted-by: opencode <opencode>
Use the public X509Certificate class instead of InternalX509Certificate for the x509 format in getCACertificates(). The public API handles PEM string-to-Buffer conversion internally and properly sets up the prototype chain, simplifying the code and addressing reviewer feedback.
getCACertificatesAsStrings already validates the type parameter, so the duplicate validateString call in getCACertificates is unnecessary.
This PR implements the TODO(joyeecheung) note to support X509Certificate output in tls.getCACertificates(). It introduces a new format option, enhancing the function's flexibility and aligning its API with Node.js's broader crypto module.
The function's behavior is now extended as follows:
API Enhancement: Adds an optional format parameter to tls.getCACertificates() to specify the output format.
Output Options: