AttributeError: '_RSAPrivateKey' object has no attribute 'sign'
See original GitHub issueWhen using a pair of RSA keys to try the example given in the docs:
encoded = jwt.encode({'some': 'payload'}, private_key, algorithm='RS256')
decoded = jwt.decode(encoded, public_key, algorithms='RS256')
Expected Result
I’m expecting to get both variables assigned without problem.
Actual Result
But what happens instead is that I’m getting:
AttributeError: '_RSAPrivateKey' object has no attribute 'sign'
Reproduction Steps
import jwt
private_key = open("private.pem").read()
public_key = open("public.pem").read()
encoded = jwt.encode({'some': 'payload'}, private_key, algorithm='RS256')
decoded = jwt.decode(encoded, public_key, algorithms='RS256')
System Information
$ python -m jwt.help
{
"cryptography": {
"version": "1.3.2"
},
"implementation": {
"name": "CPython",
"version": "3.5.1"
},
"platform": {
"release": "18.0.0",
"system": "Darwin"
},
"pyjwt": {
"version": "1.6.4"
}
}
This command is only available on PyJWT v1.6.3 and greater. Otherwise, please provide some basic information about your system.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:12
- Comments:16 (1 by maintainers)
Top Results From Across the Web
Error in python cryptography module: _RSAPrivateKey' object ...
Then use that key to sign a message. But running the program throws AttributeError: '_RSAPrivateKey' object has no attribute 'sign'.
Read more >'_RSAPrivateKey' object has no attribute 'sign' - Deployment
... my django application with travis I got the following error when I ... (AttributeError): '_RSAPrivateKey' object has no attribute 'sign'.
Read more >AttributeError: '_RSAPrivateKey' object has no attribute 'sign'
I am trying to create JWT token using python 2.7 and receive following error. AttributeError: '_RSAPrivateKey' object has no attribute 'sign' < ...
Read more >'_RSAPrivateKey' object has no attribute 'encode'
What can cause this error while running the "Sample Program for the Python SDK" for the Snowpipe REST API : '_RSAPrivateKey' object has...
Read more >Usage Examples — PyJWT 2.6.0 documentation
RSA encoding and decoding require the cryptography module. ... For example, in situations where the token issuer uses multiple keys and you have...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Make sure you don’t mix up your private key with your public. Always verify with your public key. I was using my private key to verify and got this message. Struggled with this for about 2 hours…
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