Skip to content

Support arbitrary extension types in ExtensionPolicy#14964

Merged
alex merged 2 commits into
pyca:mainfrom
reaperhulk:fix-14850
Jun 7, 2026
Merged

Support arbitrary extension types in ExtensionPolicy#14964
alex merged 2 commits into
pyca:mainfrom
reaperhulk:fix-14850

Conversation

@reaperhulk
Copy link
Copy Markdown
Member

The ExtensionPolicy builder methods (require_present, may_be_present, require_not_present) previously only accepted a fixed set of eight extension types and rejected everything else with "Unsupported extension OID". This made it impossible to account for otherwise unrecognized critical extensions (such as certificatePolicies), which would cause path validation to fail with "certificate contains unaccounted-for critical extensions".

ExtensionPolicy now keeps the eight default-handled extensions in their dedicated fields and stores any other user-added extension validators in a separate list, so any extension type can be configured.

A present extension whose value can't be parsed into a known Python object is now passed to the validator callback as an UnrecognizedExtension.

@reaperhulk reaperhulk force-pushed the fix-14850 branch 3 times, most recently from 7b2dee1 to 8065f56 Compare June 7, 2026 04:26
Comment on lines +221 to +223
policy
.additional_extensions
.retain(|existing| existing.oid() != &oid);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this retain is required -- we said registering these must be done only 1x.

The ExtensionPolicy builder methods (require_present, may_be_present,
require_not_present) previously only accepted a fixed set of eight
extension types and rejected everything else with "Unsupported extension
OID". This made it impossible to account for otherwise unrecognized
critical extensions (such as certificatePolicies), which would cause path
validation to fail with "certificate contains unaccounted-for critical
extensions".

ExtensionPolicy now keeps the eight default-handled extensions in their
dedicated fields and stores any other user-added extension validators in a
separate list, so any extension type can be configured.

A present extension whose value can't be parsed into a known Python object
is now passed to the validator callback as an UnrecognizedExtension.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment on lines +236 to +237
// `configured_oids` guarantees we haven't already stored a
// validator for this OID, so we can push without deduplicating.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slop comment, remove

@alex alex enabled auto-merge (squash) June 7, 2026 16:38
@alex alex merged commit 71f3e49 into pyca:main Jun 7, 2026
64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Unable to parse client certificates with critical 2.5.29.32 CertificatePolicies extension

2 participants