-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Fix CertificatePolicy processing. #121395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The wrong mapping variable was decremented, which could lead to incorrect AnyPolicy depth matching.
|
Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a bug in certificate policy validation where the wrong depth counter was being decremented, and adds supporting test infrastructure and a test case to verify the fix.
- Fixes a bug where
inhibitAnyPolicyDepthwas incorrectly decremented instead ofinhibitPolicyMappingDepthin the certificate policy validation logic - Adds a new overload of
MakeTestChain4that allows specifying different extensions for each intermediate certificate independently - Adds a test case to verify policy constraints work correctly with multiple intermediate certificates
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| CertificatePolicy.cs | Fixes the bug by changing the decremented variable from inhibitAnyPolicyDepth to inhibitPolicyMappingDepth |
| TestDataGenerator.cs | Adds new overload of MakeTestChain4 to support separate extension parameters for two intermediate certificates |
| DynamicChainTests.cs | Adds test case PolicyConstraints_AnyPolicyInhibited_Success and helper method BuildInhibitAnyPolicy |
src/libraries/System.Security.Cryptography/tests/X509Certificates/TestDataGenerator.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography/tests/X509Certificates/TestDataGenerator.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography/tests/X509Certificates/TestDataGenerator.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
The wrong mapping variable was decremented, which could lead to incorrect AnyPolicy depth matching. This would fail-closed, causing a policy mismatch when it shouldn't.
It should be
inhibitPolicyMappingDepth, notinhibitAnyPolicyDepth. The latter is handled on line 190.