Skip to content
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

Inconsistent IDP extension constraint check #11467

Merged
merged 2 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/cryptography/x509/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1988,18 +1988,20 @@ def __init__(
"must all be boolean."
)

# Per RFC5280 Section 5.2.5, the Issuing Distribution Point extension
# in a CRL can have only one of onlyContainsUserCerts,
# onlyContainsCACerts, onlyContainsAttributeCerts set to TRUE.
crl_constraints = [
only_contains_user_certs,
only_contains_ca_certs,
indirect_crl,
only_contains_attribute_certs,
]

if len([x for x in crl_constraints if x]) > 1:
raise ValueError(
"Only one of the following can be set to True: "
"only_contains_user_certs, only_contains_ca_certs, "
"indirect_crl, only_contains_attribute_certs"
"only_contains_attribute_certs"
)

if not any(
Expand Down
1 change: 0 additions & 1 deletion tests/x509/test_x509_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -5380,7 +5380,6 @@ def test_vectors(self, filename, expected, backend):
(TypeError, False, False, "notabool", False, None, None, None),
(TypeError, False, False, False, "notabool", None, None, None),
(ValueError, True, True, False, False, None, None, None),
(ValueError, False, False, True, True, None, None, None),
(ValueError, False, False, False, False, None, None, None),
],
)
Expand Down