Reject chains where directoryName name constraints are involved - #305
Merged
Conversation
Lukasa
approved these changes
Jul 17, 2026
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.
Motivation:
NameConstraintsPolicy(used as part ofRFC5280Policy) determines whether a certificate is valid under thedirectoryNamename constraints that are present in its issuing CA'snameConstraintsextension. It currently does so by checking for exact equality between the constraint (which appears in either thepermittedSubtreesorexcludedSubtreesfield) and the certificate's subject DN (or anydirectoryNamevalue 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.
NameConstraintsPolicyonly 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:
directoryNameMatchesConstraintmethod.NameConstraintsPolicyto simply reject chains involving adirectoryNamename constraint on both thepermittedSubtreesandexcludedSubtreespath.Result:
We now fail-safe on chains involving directoryName name constraints.