Skip to content

Reject chains where directoryName name constraints are involved - #305

Merged
aryan-25 merged 2 commits into
apple:mainfrom
aryan-25:directory-name-constraints
Jul 17, 2026
Merged

Reject chains where directoryName name constraints are involved#305
aryan-25 merged 2 commits into
apple:mainfrom
aryan-25:directory-name-constraints

Conversation

@aryan-25

@aryan-25 aryan-25 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Motivation:

NameConstraintsPolicy (used as part of RFC5280Policy) determines whether a certificate is valid under the directoryName name constraints that are present in its issuing CA's nameConstraints extension. It currently does so by checking for exact equality between the constraint (which appears in either the permittedSubtrees or excludedSubtrees field) and the certificate's subject DN (or any directoryName value in its SAN).

However, per RFC 5280 §4.2.1.10 and §7.1, a subordinate certificate's DN is within the subtree if it has at least as many RDNs as the subtree DN and the two DNs match when trailing RDNs in the subordinate's DN are ignored. Additionally, per RFC 5280 §7.1, DN attribute values must first be normalized through the LDAP StringPrep algorithm before being compared. NameConstraintsPolicy only checks exact equality; it does not check whether the subordinate's DN is within the subtree per RFC 5280 §7.1 nor applies the StringPrep normalization.

We currently do not correctly validate directoryName name constraints. Performing the validation correctly involves implementing a complex algorithm. We should therefore just reject chains where directoryName name constraints are involved.

Modifications:

  • Removed the directoryNameMatchesConstraint method.
  • Updated NameConstraintsPolicy to simply reject chains involving a directoryName name constraint on both the permittedSubtrees and excludedSubtrees path.
  • Updated all existing directoryName name constraints tests to now assert for failure.

Result:

We now fail-safe on chains involving directoryName name constraints.

@aryan-25 aryan-25 added the 🔨 semver/patch No public API change. label Jul 7, 2026
@aryan-25
aryan-25 merged commit 449dbbe into apple:main Jul 17, 2026
42 of 44 checks passed
@aryan-25
aryan-25 deleted the directory-name-constraints branch July 17, 2026 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants