-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
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
c4ca69e
tls: add 'as' option to getCACertificates() for X509Certificate output
haramj ee04b40
doc: fix getCACertificates() types and remove invalid escapes
haramj 1b8197b
doc: fix undefined reference for X509Certificate and format markdown
haramj 187c86d
Update doc/api/tls.md
haramj 4048b54
Update doc/api/tls.md
haramj eae9df7
Update doc/api/tls.md
haramj e013568
Update test/parallel/test-tls-get-ca-certificates-x509-option.js
haramj 195125f
Update doc/api/tls.md
haramj b1eacfb
tls: validate 'as' option using validateOneOf
haramj 603967f
test: expand getCACertificates() with 'as' option and invalid inputs
haramj 36e8a2e
test: expand test-tls-get-ca-certificates-x509-option.js coverage
haramj 62ec148
docs: add changes block for tls.getCACertificates ‘as’ option support
haramj 361c799
doc: fix changes block
haramj 358b2bd
tls: rename 'as' to 'format' in getCACertificates, default 'string'
haramj f9dfc62
doc: format tls.md
haramj cdf69dc
tls: simplify getCACertificates() API
haramj d978079
doc: fix broken anchor link for tls.getCACertificates()
haramj 8cf2dbe
doc: update tls.md `X509Certificate` anchor
haramj e6de951
doc: fix tls.md lint error
haramj da83ccf
doc: fix x509certificate anchor
haramj 10e9225
Update test/parallel/test-tls-get-ca-certificates-bundled.js
haramj ab76b14
doc: clarify format and return types in tls.getCACertificates()
haramj 5e8dd7a
test: fix tls.getCACertificates bundled test to use format 'string'
haramj f84c311
test: keep shorthand arguments in getCACertificates tests
haramj a335306
test: Add final newline
haramj 319841f
tls: Improve getCACertificates() caching and test
haramj fd0de18
tls: Test rollback and Update getCACertificates()
haramj 95c07aa
doc: tls.md remove the white space
haramj e2879a5
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); | ||
| } | ||
| } | ||
|
|
||
| { | ||
| 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.