| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ba17c9e commit 9f9355d
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -358,7 +358,7 @@ added: v0.5.3 | |||
| 358 | 358 | `cert`, `ca`, etc). | |
| 359 | 359 | ||
| 360 | 360 | The `server.addContext()` method adds a secure context that will be used if | |
| 361 | - the client request's SNI hostname matches the supplied `hostname` (or wildcard). | ||
| 361 | + the client request's SNI name matches the supplied `hostname` (or wildcard). | ||
| 362 | 362 | ||
| 363 | 363 | ### server.address() | |
| 364 | 364 | <!-- YAML | |
@@ -796,17 +796,17 @@ and their processing can be delayed due to packet loss or reordering. However, | |||
| 796 | 796 | smaller fragments add extra TLS framing bytes and CPU overhead, which may | |
| 797 | 797 | decrease overall server throughput. | |
| 798 | 798 | ||
| 799 | - ## tls.checkServerIdentity(host, cert) | ||
| 799 | + ## tls.checkServerIdentity(hostname, cert) | ||
| 800 | 800 | <!-- YAML | |
| 801 | 801 | added: v0.8.4 | |
| 802 | 802 | --> | |
| 803 | 803 | ||
| 804 | - * `host` {string} The hostname to verify the certificate against | ||
| 804 | + * `hostname` {string} The hostname to verify the certificate against | ||
| 805 | 805 | * `cert` {Object} An object representing the peer's certificate. The returned | |
| 806 | 806 | object has some properties corresponding to the fields of the certificate. | |
| 807 | 807 | * Returns: {Error|undefined} | |
| 808 | 808 | ||
| 809 | - Verifies the certificate `cert` is issued to host `host`. | ||
| 809 | + Verifies the certificate `cert` is issued to `hostname`. | ||
| 810 | 810 | ||
| 811 | 811 | Returns {Error} object, populating it with the reason, host, and cert on | |
| 812 | 812 | failure. On success, returns {undefined}. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -169,14 +169,14 @@ function check(hostParts, pattern, wildcards) { | |||
| 169 | 169 | return true; | |
| 170 | 170 | } | |
| 171 | 171 | ||
| 172 | - exports.checkServerIdentity = function checkServerIdentity(host, cert) { | ||
| 172 | + exports.checkServerIdentity = function checkServerIdentity(hostname, cert) { | ||
| 173 | 173 | const subject = cert.subject; | |
| 174 | 174 | const altNames = cert.subjectaltname; | |
| 175 | 175 | const dnsNames = []; | |
| 176 | 176 | const uriNames = []; | |
| 177 | 177 | const ips = []; | |
| 178 | 178 | ||
| 179 | - host = '' + host; | ||
| 179 | + hostname = '' + hostname; | ||
| 180 | 180 | ||
| 181 | 181 | if (altNames) { | |
| 182 | 182 | for (const name of altNames.split(', ')) { | |
@@ -194,14 +194,14 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) { | |||
| 194 | 194 | let valid = false; | |
| 195 | 195 | let reason = 'Unknown reason'; | |
| 196 | 196 | ||
| 197 | - if (net.isIP(host)) { | ||
| 198 | - valid = ips.includes(canonicalizeIP(host)); | ||
| 197 | + if (net.isIP(hostname)) { | ||
| 198 | + valid = ips.includes(canonicalizeIP(hostname)); | ||
| 199 | 199 | if (!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(', ')}`; | ||
| 201 | 201 | // TODO(bnoordhuis) Also check URI SANs that are IP addresses. | |
| 202 | 202 | } 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); | ||
| 205 | 205 | const wildcard = (pattern) => check(hostParts, pattern, true); | |
| 206 | 206 | const noWildcard = (pattern) => check(hostParts, pattern, false); | |
| 207 | 207 | ||
@@ -215,11 +215,12 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) { | |||
| 215 | 215 | valid = wildcard(cn); | |
| 216 | 216 | ||
| 217 | 217 | if (!valid) | |
| 218 | - reason = `Host: ${host}. is not cert's CN: ${cn}`; | ||
| 218 | + reason = `Host: ${hostname}. is not cert's CN: ${cn}`; | ||
| 219 | 219 | } else { | |
| 220 | 220 | valid = dnsNames.some(wildcard) || uriNames.some(noWildcard); | |
| 221 | 221 | if (!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}`; | ||
| 223 | 224 | } | |
| 224 | 225 | } else { | |
| 225 | 226 | reason = 'Cert is empty'; | |
@@ -228,7 +229,7 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) { | |||
| 228 | 229 | if (!valid) { | |
| 229 | 230 | const err = new ERR_TLS_CERT_ALTNAME_INVALID(reason); | |
| 230 | 231 | err.reason = reason; | |
| 231 | - err.host = host; | ||
| 232 | + err.host = hostname; | ||
| 232 | 233 | err.cert = cert; | |
| 233 | 234 | return err; | |
| 234 | 235 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments