-
-
Notifications
You must be signed in to change notification settings - Fork 35.2k
tls: use options in getCACertificates() with X509Certificate #59349
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
Open
haramj
wants to merge
29
commits into
nodejs:main
Choose a base branch
from
haramj:haramjeong-patch-250805
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+136
−17
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
670b53b
tls: add 'as' option to getCACertificates() for X509Certificate output
haramj 7a5dbcd
doc: fix getCACertificates() types and remove invalid escapes
haramj 6fe1c7b
doc: fix undefined reference for X509Certificate and format markdown
haramj ac45e9d
Update doc/api/tls.md
haramj 7c26f5e
Update doc/api/tls.md
haramj 6db6b80
Update doc/api/tls.md
haramj 5e55e1f
Update test/parallel/test-tls-get-ca-certificates-x509-option.js
haramj a9f099c
Update doc/api/tls.md
haramj 150f805
tls: validate 'as' option using validateOneOf
haramj e69b7ed
test: expand getCACertificates() with 'as' option and invalid inputs
haramj 2ac7e72
test: expand test-tls-get-ca-certificates-x509-option.js coverage
haramj c45c304
docs: add changes block for tls.getCACertificates ‘as’ option support
haramj d8a3138
doc: fix changes block
haramj 135ba8a
tls: rename 'as' to 'format' in getCACertificates, default 'string'
haramj d9e8357
doc: format tls.md
haramj e3563a5
tls: simplify getCACertificates() API
haramj fbf223a
doc: fix broken anchor link for tls.getCACertificates()
haramj 5129cb9
doc: update tls.md `X509Certificate` anchor
haramj 24b8bc2
doc: fix tls.md lint error
haramj 22ce735
doc: fix x509certificate anchor
haramj a6ebe6a
Update test/parallel/test-tls-get-ca-certificates-bundled.js
haramj a5aa848
doc: clarify format and return types in tls.getCACertificates()
haramj ba15d9f
test: fix tls.getCACertificates bundled test to use format 'string'
haramj c24e23e
test: keep shorthand arguments in getCACertificates tests
haramj 1b254d2
test: Add final newline
haramj 651a42d
tls: Improve getCACertificates() caching and test
haramj d4c3ac0
tls: Test rollback and Update getCACertificates()
haramj cea9639
doc: tls.md remove the white space
haramj e787797
tls: improve tls.getCACertificates() to simplify certificate handling
haramj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| 'use strict'; | ||
|
|
||
| const common = require('../common'); | ||
| if (!common.hasCrypto) | ||
| common.skip('missing crypto'); | ||
|
|
||
| const assert = require('assert'); | ||
| const tls = require('tls'); | ||
| const { X509Certificate } = require('crypto'); | ||
|
|
||
| { | ||
| const certs = tls.getCACertificates({ type: 'default', format: 'x509' }); | ||
| assert.ok(Array.isArray(certs)); | ||
| assert.ok(certs.length > 0); | ||
| for (const cert of certs) { | ||
| assert.ok(cert instanceof X509Certificate); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you use the helpers in test/common/tls.js to verify that they are serialized correctly (i.e. important properties are the same as before)? The same goes to the buffer results. |
||
| } | ||
| } | ||
|
|
||
| { | ||
| const certs = tls.getCACertificates({ type: 'default', format: 'buffer' }); | ||
| assert.ok(Array.isArray(certs)); | ||
| assert.ok(certs.length > 0); | ||
| for (const cert of certs) { | ||
| assert.ok(Buffer.isBuffer(cert)); | ||
| } | ||
| } | ||
|
|
||
| { | ||
| const certs = tls.getCACertificates({ type: 'default' }); | ||
| assert.ok(Array.isArray(certs)); | ||
| assert.ok(certs.length > 0); | ||
| for (const cert of certs) { | ||
| assert.strictEqual(typeof cert, 'string'); | ||
| assert.ok(cert.includes('-----BEGIN CERTIFICATE-----')); | ||
| } | ||
| } | ||
|
|
||
| { | ||
| assert.throws(() => { | ||
| tls.getCACertificates({ type: 'default', format: 'invalid' }); | ||
| }, { | ||
| name: 'TypeError', | ||
| code: 'ERR_INVALID_ARG_VALUE', | ||
| message: /must be one of/ | ||
| }); | ||
| } | ||
|
|
||
| { | ||
| const certs = tls.getCACertificates({ format: 'buffer' }); | ||
| assert.ok(Array.isArray(certs)); | ||
| assert.ok(certs.length > 0); | ||
| for (const cert of certs) { | ||
| assert.ok(Buffer.isBuffer(cert)); | ||
| } | ||
| } | ||
|
|
||
| { | ||
| assert.throws(() => { | ||
| tls.getCACertificates({ type: 'invalid', format: 'buffer' }); | ||
| }, { | ||
| name: 'TypeError', | ||
| code: 'ERR_INVALID_ARG_VALUE', | ||
| message: "The argument 'type' is invalid. Received 'invalid'" | ||
| }); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.