You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
undefined is passed as hostname to tls.checkServerIdentity #1489
Yeah, something is a bit fishy here, it's strange that tls.connect does throw in this case, when the docs for the secureConnect event say
This event is emitted after a new connection has been successfully handshaked. The listener will be called no matter if the server's certificate was authorized or not.
Above self-signed cert seems to be authorized by the ca option, I'm not sure the throw is correct in this case.
@Fishrock123 Regarding existing tests: They mostly use rejectUnauthorized: false which suppresses the cert errors. test-tls-connect being the exception, it connects to an nonexistant server.
Still, the fact that tls.connect does throw on cert errors puzzles me, maybe the docs aren't up to date?
Activity
sitegui commentedon Apr 21, 2015
Code's better than words:
Fishrock123 commentedon Apr 21, 2015
Do note this is now public. :)
Hmm, so, confirmed from that test case, and this patch appears to fix it:
However, our tests don't appear to specify a host and yet they don't have a problem? I'm kinda confused.
silverwind commentedon Apr 21, 2015
That cert is self-signed for
localhost, so no issue :)I think the suggested fix is spot-on. @sitegui would you like to submit a PR with this patch and your test case added?
silverwind commentedon Apr 21, 2015
@Fishrock123's patch looks to be safer than adding it to
defaults.Fishrock123 commentedon Apr 21, 2015
Again, see the above, not so sure.
For the test, I suggest just using the built in certs that are read from fs in other tests.
silverwind commentedon Apr 21, 2015
Yeah, something is a bit fishy here, it's strange that
tls.connectdoes throw in this case, when the docs for thesecureConnectevent sayAbove self-signed cert seems to be authorized by the
caoption, I'm not sure the throw is correct in this case.cc: @indutny
silverwind commentedon Apr 21, 2015
@Fishrock123 Regarding existing tests: They mostly use
rejectUnauthorized: falsewhich suppresses the cert errors.test-tls-connectbeing the exception, it connects to an nonexistant server.Still, the fact that
tls.connectdoes throw on cert errors puzzles me, maybe the docs aren't up to date?silverwind commentedon Apr 21, 2015
Nevermind my error ramblings, I was just confused about how errors were returned here.
The
test_cert.pemour tests use are already signed tolocalhost, so they're fine to test this with.sitegui commentedon Apr 21, 2015
Thanks for the quick follow up guys.
@Fishrock123
It was already, no problem.
@silverwind
Yes, I'll do this is a moment.
@silverwind
It seems a better solution indeed, since
hostmust be present only if neitherservernamenorsocketare set.tls_wrap: use localhost if options.host is empty
silverwind commentedon Apr 23, 2015
Fixed in a7d7463
tls_wrap: use localhost if options.host is empty
tls_wrap: use localhost if options.host is empty