python - Python 3.7 Authlib UnsupportedAlgorithmError
问题描述
我在 Docker 中的 Ubuntu 18.04 上有这个问题。当我在 macOS 上开发这个应用程序时,没有这样的错误。
我用这个 Dockerfile 构建图像:https ://pastebin.com/rG32a0dv
要求.txt:
Flask==1.0.2
uWSGI==2.0.17.1
Authlib==0.10
cryptography==2.3.1
代码中的用法:
header = {'alg': 'RS256'}
payload = {'login': login}
auth_token = jwt.encode(header, payload, private_key)
和
try:
claims = jwt.decode(auth_token, public_key)
except BadSignatureError:
return False
整个 Flask 应用程序:https ://pastebin.com/9vVJQL1w
我有错误:
authlib.specs.rfc7515.errors.UnsupportedAlgorithmError: unsupported_algorithm:
详情:https ://pastebin.com/MjFRce1F
为什么会出现这个错误?我能做些什么来修复它?
解决方案
密码学没有manylinux
适用于 CPython 3.7 的轮子。在这种情况下,您需要自己在 linux 上构建密码学。遵循文档:
https://cryptography.io/en/latest/installation/#building-cryptography-on-linux
您可以尝试导入一些密码学模块来验证:
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric.utils import (
decode_dss_signature, encode_dss_signature
)
from cryptography.hazmat.primitives.asymmetric.ec import ECDSA
from cryptography.hazmat.primitives.asymmetric import padding
通过https://github.com/lepture/authlib/blob/v0.10/authlib/specs/rfc7518/_backends/_jws_cryptography.py
推荐阅读
- firebase - Firebase 实时数据库中的查询成本是多少?
- rest - 没有输入时,如何修复邮递员应用程序中的 POST 请求错误?
- ruby-on-rails - rails - 设计 - 退出时未定义的方法“remember_created_at”
- react-native - 世博分离和世博弹出有什么区别?
- javascript - Polar Area onclick 事件
- assembly - 如何计算 mips 汇编编程的时钟周期?
- javascript - VS Code 在我使用 console.log 时自动导入控制台
- python - 数据框中所有可能组的自定义分组,其中缺少值
- javascript - 如何附加获取 HTML
- javascript - AngularJs ng-repeat 将颜色添加到相关列中单元格的最大值