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

Ignore Content-Type header when certificate of type PEM is detected #9

Merged
Merged
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
20 changes: 1 addition & 19 deletions pyhanko_certvalidator/fetchers/common_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,6 @@
)


ACCEPTABLE_PKCS7_PEM_ALIASES = frozenset(

Choose a reason for hiding this comment

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

👍

[
'application/x-pem-file',
'text/plain',
'application/pkcs7-mime',
'application/x-pkcs7-certificates',
'binary/octet-stream',
]
)


def unpack_cert_content(
response_data: bytes,
content_type: Optional[str],
Expand All @@ -99,14 +88,7 @@ def unpack_cert_content(
yield x509.Certificate.load(response_data)
elif (content_type in ACCEPTABLE_PKCS7_DER_ALIASES) and not is_pem:
yield from _unpack_der_pkcs7(response_data, url)
elif (
permit_pem
and is_pem
and (
content_type in ACCEPTABLE_CERT_PEM_ALIASES
or content_type in ACCEPTABLE_PKCS7_PEM_ALIASES
)
):
elif permit_pem and is_pem:
# technically, PEM is not allowed here, but of course some people don't
# bother following the rules
for type_name, _, data in pem.unarmor(response_data, multiple=True):
Expand Down
Loading