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

Handle load_pem_public_key ValueError #952

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

CollinEMac
Copy link

This is a stab at addressing the issue discussed here: Consider cryptography 42.x.x new validation #948

All I did is raise a InvalidKeyError when there is a ValueError and return cast(RSAPublicKey, load_pem_public_key(key_bytes)) fails.

return cast(RSAPublicKey, load_pem_public_key(key_bytes))
try:
return cast(RSAPublicKey, load_pem_public_key(key_bytes))
except (ValueError, UnsupportedAlgorithm):
Copy link
Owner

Choose a reason for hiding this comment

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

can we add a test that covers this behavior when using the version of cryptography that introduces the behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants