doc: fix inconsistent documentation (host vs hostname) · nodejs/node@9f9355d
@@ -169,14 +169,14 @@ function check(hostParts, pattern, wildcards) {
169169return true;
170170}
171171172-exports.checkServerIdentity = function checkServerIdentity(host, cert) {
172+exports.checkServerIdentity = function checkServerIdentity(hostname, cert) {
173173const subject = cert.subject;
174174const altNames = cert.subjectaltname;
175175const dnsNames = [];
176176const uriNames = [];
177177const ips = [];
178178179-host = '' + host;
179+hostname = '' + hostname;
180180181181if (altNames) {
182182for (const name of altNames.split(', ')) {
@@ -194,14 +194,14 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) {
194194let valid = false;
195195let reason = 'Unknown reason';
196196197-if (net.isIP(host)) {
198-valid = ips.includes(canonicalizeIP(host));
197+if (net.isIP(hostname)) {
198+valid = ips.includes(canonicalizeIP(hostname));
199199if (!valid)
200-reason = `IP: ${host} is not in the cert's list: ${ips.join(', ')}`;
200+reason = `IP: ${hostname} is not in the cert's list: ${ips.join(', ')}`;
201201// TODO(bnoordhuis) Also check URI SANs that are IP addresses.
202202} else if (subject) {
203-host = unfqdn(host); // Remove trailing dot for error messages.
204-const hostParts = splitHost(host);
203+hostname = unfqdn(hostname); // Remove trailing dot for error messages.
204+const hostParts = splitHost(hostname);
205205const wildcard = (pattern) => check(hostParts, pattern, true);
206206const noWildcard = (pattern) => check(hostParts, pattern, false);
207207@@ -215,11 +215,12 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) {
215215valid = wildcard(cn);
216216217217if (!valid)
218-reason = `Host: ${host}. is not cert's CN: ${cn}`;
218+reason = `Host: ${hostname}. is not cert's CN: ${cn}`;
219219} else {
220220valid = dnsNames.some(wildcard) || uriNames.some(noWildcard);
221221if (!valid)
222-reason = `Host: ${host}. is not in the cert's altnames: ${altNames}`;
222+reason =
223+`Host: ${hostname}. is not in the cert's altnames: ${altNames}`;
223224}
224225} else {
225226reason = 'Cert is empty';
@@ -228,7 +229,7 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) {
228229if (!valid) {
229230const err = new ERR_TLS_CERT_ALTNAME_INVALID(reason);
230231err.reason = reason;
231-err.host = host;
232+err.host = hostname;
232233err.cert = cert;
233234return err;
234235}