jpadilla / pyjwt

JSON Web Token implementation in Python
https://pyjwt.readthedocs.io
MIT License
4.99k stars 676 forks source link

Handle load_pem_public_key ValueError #952

Closed CollinEMac closed 3 weeks ago

CollinEMac commented 3 months ago

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.

fix https://github.com/jpadilla/pyjwt/issues/948

codespearhead commented 1 month ago

@CollinEMac Can you link this PR to issue #948 ?

To do this, you just need to add the following to the end of the PR description:

fix #948