mirror of
https://github.com/apple/swift-certificates
synced 2026-11-24 04:27:49 +00:00
### Motivation `NameConstraintsPolicy` read an all-zero CIDR mask as matching nothing. An all-zero mask constrains no bits, so it matches every address: the CA/Browser Forum Baseline Requirements express "this subordinate CA must not issue for IP addresses" as `excludedSubtrees` of `0.0.0.0/0` and `::/0`, and against this code those exclusions constrained nothing, so a leaf with an IP SAN under such a CA verified. ### Modifications The leading-zero shortcut in `isValidCIDRMask` is removed and the general leading-ones-then-zeros check decides. The two `IPAddressNameTests` rows that pinned the old reading now expect a match. `testAllZeroMaskIsValidCIDRMask` asserts the IPv4 and IPv6 all-zero masks directly, and two `RFC5280PolicyTests1` tests run `RFC5280Policy` with `0.0.0.0/0` and `::/0` as permitted and as excluded subtrees. All of them fail on main. ### Result A `/0` iPAddress constraint covers the whole address space, as RFC 5280 4.2.1.10 defines it. `swift test` passes under the CI flags (`-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable`) on Swift 6.1.2; `swift-format lint --strict` is clean on the changed files. --------- Co-authored-by: Raphael Hiesgen <r_hiesgen@apple.com>