-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
doc: fix inconsistent documentation (host vs hostname) #20933
Changes from all commits
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 |
---|---|---|
|
@@ -161,14 +161,14 @@ function check(hostParts, pattern, wildcards) { | |
} | ||
|
||
let urlWarningEmitted = false; | ||
exports.checkServerIdentity = function checkServerIdentity(host, cert) { | ||
exports.checkServerIdentity = function checkServerIdentity(hostname, cert) { | ||
const subject = cert.subject; | ||
const altNames = cert.subjectaltname; | ||
const dnsNames = []; | ||
const uriNames = []; | ||
const ips = []; | ||
|
||
host = '' + host; | ||
hostname = '' + hostname; | ||
|
||
if (altNames) { | ||
for (const name of altNames.split(', ')) { | ||
|
@@ -200,14 +200,14 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) { | |
let valid = false; | ||
let reason = 'Unknown reason'; | ||
|
||
if (net.isIP(host)) { | ||
valid = ips.includes(canonicalizeIP(host)); | ||
if (net.isIP(hostname)) { | ||
valid = ips.includes(canonicalizeIP(hostname)); | ||
if (!valid) | ||
reason = `IP: ${host} is not in the cert's list: ${ips.join(', ')}`; | ||
reason = `IP: ${hostname} is not in the cert's list: ${ips.join(', ')}`; | ||
// TODO(bnoordhuis) Also check URI SANs that are IP addresses. | ||
} else if (subject) { | ||
host = unfqdn(host); // Remove trailing dot for error messages. | ||
const hostParts = splitHost(host); | ||
hostname = unfqdn(hostname); // Remove trailing dot for error messages. | ||
const hostParts = splitHost(hostname); | ||
const wildcard = (pattern) => check(hostParts, pattern, true); | ||
const noWildcard = (pattern) => check(hostParts, pattern, false); | ||
|
||
|
@@ -221,11 +221,12 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) { | |
valid = wildcard(cn); | ||
|
||
if (!valid) | ||
reason = `Host: ${host}. is not cert's CN: ${cn}`; | ||
reason = `Host: ${hostname}. is not cert's CN: ${cn}`; | ||
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. Nit: should we also change the message prefix from 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. @lpinca Hard to say. It's an error with a code ( Additionally, the period seems to be an error and should be removed here and in line 229. EDIT: Oh, yeah, we're also setting |
||
} else { | ||
valid = dnsNames.some(wildcard) || uriNames.some(noWildcard); | ||
if (!valid) | ||
reason = `Host: ${host}. is not in the cert's altnames: ${altNames}`; | ||
reason = | ||
`Host: ${hostname}. is not in the cert's altnames: ${altNames}`; | ||
} | ||
} else { | ||
reason = 'Cert is empty'; | ||
|
@@ -234,7 +235,7 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) { | |
if (!valid) { | ||
const err = new ERR_TLS_CERT_ALTNAME_INVALID(reason); | ||
err.reason = reason; | ||
err.host = host; | ||
err.host = hostname; | ||
err.cert = cert; | ||
return err; | ||
} | ||
|
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 corresponding change needs to also be made in
lib/tls.js
so that argument names in error messages and stack traces match those in documentation.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.
@Trott Made changes to
lib/tls.js
as well