| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3f8b446 commit b9104de
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -431,8 +431,14 @@ exports.checkServerIdentity = function checkServerIdentity(hostname, cert) { | |||
| 431 | 431 | let valid = false; | |
| 432 | 432 | let reason = 'Unknown reason'; | |
| 433 | 433 | ||
| 434 | - if (net.isIP(hostnameASCIIWithoutFQDN)) { | ||
| 435 | - valid = ips.includes(canonicalizeIP(hostnameASCIIWithoutFQDN)); | ||
| 434 | + // An IP literal must not be IDNA-normalized: domainToASCII() returns '' for | ||
| 435 | + // an IPv6 literal (it is not a domain), so matching against the normalized | ||
| 436 | + // host would skip IP-SAN matching for IPv6 entirely. Match IP hosts against | ||
| 437 | + // the original hostname (net.isIP() rejects non-ASCII, so there is no IDNA | ||
| 438 | + // confusion to guard against here); the normalized form is kept for the | ||
| 439 | + // DNS-name path below. | ||
| 440 | + if (net.isIP(hostname)) { | ||
| 441 | + valid = ips.includes(canonicalizeIP(hostname)); | ||
| 436 | 442 | if (!valid) { | |
| 437 | 443 | reason = | |
| 438 | 444 | `IP: ${hostname} is not in the cert's list: ` + ips.join(', '); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -100,6 +100,27 @@ const tests = [ | |||
| 100 | 100 | cert: { subject: { CN: '8.8.8.8' }, subjectaltname: 'IP Address:8.8.8.8' } | |
| 101 | 101 | }, | |
| 102 | 102 | ||
| 103 | + // An "IP Address:" SAN also matches an IPv6 host. Regression test for the | ||
| 104 | + // IDNA-normalization change: domainToASCII('::1') === '' (an IPv6 literal is | ||
| 105 | + // not a domain), which made the normalized host skip IPv6 IP-SAN matching. | ||
| 106 | + { | ||
| 107 | + host: '::1', | ||
| 108 | + cert: { subject: {}, subjectaltname: 'IP Address:::1' } | ||
| 109 | + }, | ||
| 110 | + | ||
| 111 | + // IPv6 hosts and SANs are matched canonically. | ||
| 112 | + { | ||
| 113 | + host: '2001:db8::1', | ||
| 114 | + cert: { subject: {}, subjectaltname: 'IP Address:2001:DB8:0:0:0:0:0:1' } | ||
| 115 | + }, | ||
| 116 | + | ||
| 117 | + // A non-matching IPv6 "IP Address:" SAN is rejected. | ||
| 118 | + { | ||
| 119 | + host: '::1', | ||
| 120 | + cert: { subject: {}, subjectaltname: 'IP Address:::2' }, | ||
| 121 | + error: 'IP: ::1 is not in the cert\'s list: ::2' | ||
| 122 | + }, | ||
| 123 | + | ||
| 103 | 124 | // But not when it's a CIDR. | |
| 104 | 125 | { | |
| 105 | 126 | host: '8.8.8.8', | |
| Back | FazBrowse Home | New Git URL |
0 commit comments