-
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_wrap: use localhost if options.host is empty #1493
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
var common = require('../common'); | ||
|
||
if (!common.hasCrypto) { | ||
console.log('1..0 # Skipped: missing crypto'); | ||
process.exit(); | ||
} | ||
var tls = require('tls'); | ||
|
||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
var cert = fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem')); | ||
var key = fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')); | ||
|
||
// https://github.com/iojs/io.js/issues/1489 | ||
// tls.connect(options) with no options.host should accept a cert with CN:'localhost' | ||
tls.createServer({ | ||
key: key, | ||
cert: cert | ||
}).listen(common.PORT); | ||
|
||
tls.connect({ | ||
port: common.PORT, | ||
ca: cert, | ||
// No host set here. 'localhost' is the default, | ||
// but tls.checkServerIdentity() breaks before the fix with: | ||
// Error: Hostname/IP doesn't match certificate's altnames: "Host: undefined. is not cert's CN: localhost" | ||
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. wrap at 80 columns please :) |
||
}, function () { | ||
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. style nit: no space before the |
||
console.log('OK'); | ||
process.exit(); | ||
}); | ||
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. Could you add a terminating newline here so we don't get annoying diff changes 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.
Don't these need to be in parenthesis? Otherwise it will overlap, no?
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 don't think they will overlap, but it's much better with
()
for sureThere 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.
No, Boolean logic defines and at higher precedence than or. So does JavaScript. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
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 is unnecessary, as @kkoopa said:
&&
has higher precedence. I just added the( )
to make the intent clearer to the eye, since the precendence is not obvious.What's the recommended style for this situation?
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.
Generally we prefer shorter I think, but no harm in adding a few clarity parens, I'd say.