-
-
Notifications
You must be signed in to change notification settings - Fork 696
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
RSA256 not supported despite having cryptography (was: pycrypto) installed #181
Comments
Thanks for reporting @wsw70. One small thing first. You don't need to include the Regarding your actual issue... some time ago we switched to using If you are unable to install You can setup the legacy support for algorithms by doing the following:
|
Thank you for the clear answer, I will go for |
Legacy fix fixed for me as well. |
@mark-adams , Thanks, your answer fix my problem as well. |
TL;DR: do not make my mistake, do not install PyJWT via the OS package manager. In other words RTFM which tells to install vi a I still kept below the story of my bumpy journey, just in case I am back here again I needed to install my script on another machine (the current one was working fine, honestly I do not remember how I managed to make it swallow the RS256 algorithm but it works untouched for 9 months) and I bumped against the same issue. Installing The solution I used was not to switch to the legacy behaviour @mark-adams suggested (otherwise it would have worked on the new install) . For the sake of our civilization (and in case I am back here again) - the whole story on what to install and what not (on a RP with raspbiani, so a debian derivative but it may be the same on other distros). I installed Tried a
After that I removed the package and installed |
I started from a fresh install of Windows (python 3.5), installed Is there anything special I need to do in order to decal re this algorithm to |
@wsw70 No, that should work. Are you sure that both |
@mark-adams I moved the development of my soft to docker and ran into the same problem (I am a bit desperate but at least googling the issue brings be back here :)) The Dockerfile (which builds the docker container) calls
This is on an Ubuntu 16.10 (yakkety) When starting my program I run into
|
@mark-adams I started once again (on a clean distribution), this time not installing There must be something wrong with the version in the distribution. |
That makes sense. Probably should file a bug with the upstream distro. Thanks for looking into it. |
@mark-adams
raise ValueError('Algorithm already has a handler.') |
I have the same problem like a @pcwang0205 . |
I have also got same problem @pcwang0205 and @charlesasilva61 . Is this problem solved? |
@goginenir6
|
Had the same problem, the solution was just to delete line with jwt.register_algorithm() |
@apple-blossom:
I'm guessing the right suggestion is to use |
If anyone is getting the "Algorithm already has a handler" problem, there's a simple fix. Unregister the original handler first. import jwt
# Tell pyjwt to use pycrypto instead of cryptography, which isn't available on GAE
# https://github.com/jpadilla/pyjwt/blob/master/docs/installation.rst#legacy-dependencies
from jwt.contrib.algorithms.py_ecdsa import ECAlgorithm
jwt.unregister_algorithm('ES256')
jwt.register_algorithm('ES256', ECAlgorithm(ECAlgorithm.SHA256)) |
Related to #181 where users see `ValueError: Algorithm already has a handler.` after trying to register pycrypto algorithms.
I think it worth to mention |
Adding |
👍 add to readme please. Or better yet, add to |
We need to update docs, but |
I am trying to use , PS256 and getting below error, if I change algorithm for HS256 code is working well and good. below is the error I am getting. NotImplementedError: Algorithm 'PS256' could not be found. Do you have cryptogra |
@Deepakthakur53 : so you have Also please look at my TL;DR comment (#181 (comment)) where I found out that all this needs to be installed via I use |
Any idea/workaround for someone like me who wants to use |
I don't normally add to things like this, but I spent two days trying to resolve this exact error in an AWS Lambda. Using the correct python / pip version to match my environment, and installing cryptography and then pyjwt was key, however I would have solved it a lot sooner if I had realized that in AWS Lambda, the layer version attached to your Lambda Function does not always automatically update when you create a new layer version. |
Python 3.2.3 on a RPi (
Linux raspberrypi 3.18.11+ #781 PREEMPT Tue Apr 21 18:02:18 BST 2015 armv6l GNU/Linux
).PyCrypto is installed:
python3-dev
andpython3-crypto
are installed as well. Note: the same issue is present whether either ofpycrypto
orpython3-crypto
are installed, or both, or neither.The following call crashes with an unsupported algorithm:
myjwt = jwt.encode(claim, private_key, algorithm='RS256', headers={"alg": "RS256", "typ": "JWT"}).decode('utf-8')
The text was updated successfully, but these errors were encountered: