Repository navigation
Match Node's canonicalizeIP for IPv6 zone ids - #8609
Merged
Merged
Conversation
tls.checkServerIdentity() canonicalizes the host and each "IP Address:" SAN with node:url's internal canonicalizeIp. Node does this with uv_inet_pton and uv_inet_ntop, which drop an IPv6 zone id and print an IPv4-compatible address as ::a.b.c.d. workerd parsed with Rust's IpAddr, which rejects "fe80::1%eth0", so a host or SAN with a zone id never matched (Node: valid; workerd: "IP: fe80::1%eth0 is not in the cert's list: fe80::1"), and a SAN of 0:0:0:0:0:0:102:304 showed up as ::102:304 in the error. In this patch canonicalize_ip parses IPv4 on the whole input, cuts IPv6 input at the first '%', and writes IPv4-compatible addresses in dotted form. A mismatch turning into a match is additive, so there is no compatibility flag.
There was a problem hiding this comment.
✅ Approved — No issues found: the new canonicalize_ip matches libuv's inet_pton/inet_ntop handling of zone ids and IPv4-compatible addresses, and the new tests cover it.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
📋 Code Quality: ✅ LGTM
I compared canonicalize_ip with libuv's uv_inet_pton / uv_inet_ntop and found no issues.
- Zone ids: the cut at the first
%matches libuv. - Order of parsing: IPv4 is tried on the whole input first, as in libuv.
- Dotted output: the
::a.b.c.dcondition is the same asinet_ntop6's six-zero-word case. - IPv4-mapped addresses: these already print in dotted form through Rust's
Display. - Tests: the Rust and JS cases cover zone stripping, the empty zone, IPv4 with a zone, compatible and mapped forms,
::0.0.0.1and::.
📝 Documentation: ✅ LGTM
The updated doc comment on canonicalizeIp describes what the code now does.
Reviewed commit: 5f6d7490
jasnell
approved these changes
Nov 18, 2026
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tls.checkServerIdentity()canonicalizes the host and eachIP Address:SAN with node:url's internalcanonicalizeIp. Node does this withuv_inet_ptonanduv_inet_ntop. Those drop an IPv6 zone id and print an IPv4-compatible address as::a.b.c.d. workerd parsed the address with Rust'sIpAddr, which rejectsfe80::1%eth0, so a host or SAN with a zone id never matched:A SAN of
0:0:0:0:0:0:102:304also showed up as::102:304in the error message, where Node prints::1.2.3.4.In this patch
canonicalize_ipparses IPv4 on the whole input, cuts IPv6 input at the first%, and writes IPv4-compatible addresses in dotted form. A mismatch turning into a match is additive, so this ships without a compatibility flag. The newurl-test.rscases and the threecheckServerIdentitycases in tls-nodejs-test fail without the fix.