-
-
Notifications
You must be signed in to change notification settings - Fork 687
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
Error TypeError: ECPublicKey.verify() takes 3 positional arguments but 4 were given
while using jwt.decode
#964
Comments
Exact same problem in 2.9.0.
|
Can you check what >>> from cryptography.hazmat.primitives.serialization import load_pem_public_key
>>> your_key = "..." # unicode string, or you if you already have it as bytes skip the encode() below
>>> type(load_pem_public_key(your_key.encode("utf-8"))) (if |
Yes, my problem was caused because I was taking the wrong key from the JWKS endpoint of my openid-configuration. I was taking the first one that it is in fact an elliptic curve key ( Using a |
I do feel like we should catch these issues where the key passed in is from the wrong algo-family (and, ideally, down to ensuring the same algo was used). I can attempt a PR this week if that's the approach we want to take. |
Yes, maybe it should warn you (or throw you) in some way that you are trying to verify with an ECPublicKey when the algorithm you specified is RS256. But if we are already detecting the key algorithm and we know the algorithm passed by the user, we could catch the error and be more specific. Only my two cents as an user, I'm by no means an expert in this. I'm glad to help if needed. |
Draft PR, so we have something to look at while proposing a "fix" for this. |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days |
Getting this error
TypeError: ECPublicKey.verify() takes 3 positional arguments but 4 were given
while trying to decode a token with RS256 algorithm.Expected Result
Decode some token via jwt.decode
Actual Result
Reproduction Steps
System Information
The text was updated successfully, but these errors were encountered: