-
-
Notifications
You must be signed in to change notification settings - Fork 35.9k
tls: include OpenSSL CAs in default CA list #64269
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
Archkon
wants to merge
2
commits into
nodejs:main
Choose a base branch
from
Archkon:tls
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.
+128
−4
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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,17 @@ | ||
| 'use strict'; | ||
|
|
||
| const assert = require('assert'); | ||
| const fs = require('fs'); | ||
| const tls = require('tls'); | ||
| const { includesCert } = require('../common/tls'); | ||
|
|
||
| const expectedCertFiles = process.env.EXPECTED_CERT_FILES ? | ||
| JSON.parse(process.env.EXPECTED_CERT_FILES) : [process.env.SSL_CERT_FILE]; | ||
| const defaultCerts = tls.getCACertificates('default'); | ||
|
|
||
| for (const certFile of expectedCertFiles) { | ||
| const expected = fs.readFileSync(certFile, 'utf8'); | ||
| assert(includesCert(defaultCerts, expected)); | ||
| } | ||
| assert.strictEqual(defaultCerts, tls.getCACertificates()); | ||
| assert.strictEqual(defaultCerts, tls.getCACertificates('default')); |
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,43 @@ | ||
| 'use strict'; | ||
|
|
||
| // This tests that tls.getCACertificates('default') includes certificates from | ||
| // OpenSSL's default certificate file and directories when --use-openssl-ca is | ||
| // enabled. | ||
|
|
||
| const common = require('../common'); | ||
| if (!common.hasCrypto) common.skip('missing crypto'); | ||
|
|
||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const { spawnSyncAndExitWithoutError } = require('../common/child_process'); | ||
| const fixtures = require('../common/fixtures'); | ||
| const tmpdir = require('../common/tmpdir'); | ||
|
|
||
| tmpdir.refresh(); | ||
|
|
||
| const firstCertDir = tmpdir.resolve('openssl-certs-1'); | ||
| const secondCertDir = tmpdir.resolve('openssl-certs-2'); | ||
| fs.mkdirSync(firstCertDir); | ||
| fs.mkdirSync(secondCertDir); | ||
|
|
||
| const expectedCertFiles = [ | ||
| fixtures.path('keys', 'ca1-cert.pem'), | ||
| fixtures.path('keys', 'ca2-cert.pem'), | ||
| fixtures.path('keys', 'ca3-cert.pem'), | ||
| ]; | ||
| fs.copyFileSync(expectedCertFiles[1], path.join(firstCertDir, 'ca2-cert.pem')); | ||
| fs.copyFileSync(expectedCertFiles[2], path.join(secondCertDir, 'ca3-cert.pem')); | ||
|
|
||
| spawnSyncAndExitWithoutError( | ||
| process.execPath, | ||
| ['--use-openssl-ca', fixtures.path('tls-check-openssl-ca-certificates.js')], | ||
| { | ||
| env: { | ||
| ...process.env, | ||
| EXPECTED_CERT_FILES: JSON.stringify(expectedCertFiles), | ||
| NODE_EXTRA_CA_CERTS: undefined, | ||
| SSL_CERT_FILE: expectedCertFiles[0], | ||
| SSL_CERT_DIR: [firstCertDir, secondCertDir].join(path.delimiter), | ||
| }, | ||
| }, | ||
| ); |
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
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.
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.
I think we need to document that the certificates queried this way will diverge from what
--use-openssl-caactually uses to verify the certificates:--use-system-cadiffers in that it trusts all certificates from the directories without the hash lookup, which is also e.g. what go's client does, but--use-openssl-caactually filters https://docs.openssl.org/1.1.1/man3/X509_LOOKUP_hash_dir/#hashed-directory-methodI am somewhat skeptical whether this should be implemented without a hash lookup, though. Another workaround is to accept a second parameter that indicates the ceritifcate/subject name we are filtering for. I think we will also need a
'openssl'type that takes this filtering argument.Uh oh!
There was an error while loading. Please reload this page.
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.
It seems that hash lookup semantics are specific to the OpenSSL CA store. Adding an extra argument to this method for that case may blur the existing API semantics, since
getCACertificates()currently behaves like an enumeration API. Would a separate API ( liketls.lookupCACertificates)for OpenSSL-style lookup be a cleaner design?