-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
tls: support reading multiple cas from one input #4099
Merged
Merged
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 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 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,35 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const tls = require('tls'); | ||
const fs = require('fs'); | ||
|
||
const ca1 = | ||
fs.readFileSync(`${common.fixturesDir}/keys/ca1-cert.pem`, `utf8`); | ||
const ca2 = | ||
fs.readFileSync(`${common.fixturesDir}/keys/ca2-cert.pem`, `utf8`); | ||
const cert = | ||
fs.readFileSync(`${common.fixturesDir}/keys/agent3-cert.pem`, `utf8`); | ||
const key = | ||
fs.readFileSync(`${common.fixturesDir}/keys/agent3-key.pem`, `utf8`); | ||
|
||
function test(ca, next) { | ||
const server = tls.createServer({ ca, cert, key }, function(conn) { | ||
this.close(); | ||
conn.end(); | ||
}); | ||
|
||
server.addContext('agent3', { ca, cert, key }); | ||
|
||
const host = common.localhostIPv4; | ||
const port = common.PORT; | ||
server.listen(port, host, function() { | ||
tls.connect({ servername: 'agent3', host, port, ca }); | ||
}); | ||
|
||
server.once('close', next); | ||
} | ||
|
||
const array = [ca1, ca2]; | ||
const string = ca1 + '\n' + ca2; | ||
test(array, () => test(string, () => {})); |
This file contains 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
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.
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.
Let's do
while (true)
here, and break in loop ifx509 === nullptr
. I don't think that this deserves disabling lint rules.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.
The NOLINT works around what I suspect is a bug in the lint rule. If you put the
while
on a single line (ands/nullptr/0/
to keep it < 80 columns) it won't trigger.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.
idk, it doesn't look like a good code style to me, splitting while's condition between lines. That's just my opinion, though
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.
/cc @trevnorris - you can be the arbitrator.
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.
Is the following not possible?
If not, I'd say how it is now isn't the prettiest but personally find it easier to logically follow. Which wins for me.