Nav*_*een 9 python django cryptography google-compute-engine
我有一个与Python中的Cryptography包相关的问题.如果可能的话,你能帮忙解决这些问题吗?(尝试了很多,但无法找出确切的解决方案)
启动此错误的python代码:
print("Salt: %s" % salt)
server_key = pyelliptic.ECC(curve="prime256v1") # ----->> Line2
print("Server_key: %s" % server_key) # ----->> Line3
server_key_id = base64.urlsafe_b64encode(server_key.get_pubkey()[1:])
http_ece.keys[server_key_id] = server_key
http_ece.labels[server_key_id] = "P-256"
encrypted = http_ece.encrypt(data, salt=salt, keyid=server_key_id,
dh=self.receiver_key, authSecret=self.auth_key) # ----->> Line8
Run Code Online (Sandbox Code Playgroud)
"盐"的值在100%的情况下显示.
如果Line3成功执行,由于http_ece.encrypt()调用(Line8),我看到以下入口点错误:
AttributeError("'EntryPoint' object has no attribute 'resolve'",)
Run Code Online (Sandbox Code Playgroud)
(参考文件链接:https://github.com/martinthomson/encrypted-content-encoding/blob/master/python/http_ece/init.py#L128)
Requirements.txt(部分):
cryptography==1.5
pyelliptic==1.5.7
pyOpenSSL==16.1.0
Run Code Online (Sandbox Code Playgroud)
在运行命令:sudo pip freeze --all |grep setuptools,我得到:
setuptools==27.1.2
如果需要更多细节,请告诉我.
这个问题似乎是基本上是由于安装在VM中的一些旧的/不兼容包(与PyElliptic,密码学,PyOpenSSL和/或setuptools的).供参考:https://github.com/pyca/cryptography/issues/3149
有人可以建议一个很好的解决方案来完全解决这个问题吗?
谢谢,
从项目路径 /opt/projects/myproject-google/myproject 运行以下命令,它解决了属性入口点错误问题:
(假设项目虚拟环境路径为:/opt/projects/myproject-google/venv)
命令:(来自路径:/opt/projects/myproject-google/myproject)
export PYTHONPATH= # [Blank]
sudo pip install --upgrade virtualenv setuptools
sudo rm -rf ../venv
sudo virtualenv ../venv
source ../venv/bin/activate
sudo pip install --upgrade -r requirements.txt
deactivate
Run Code Online (Sandbox Code Playgroud)
运行上述命令升级了虚拟环境和虚拟环境中的 setuptools 版本。位于路径:/opt/projects/myproject-google/venv/lib/python2.7/site-packages。要测试 setuptools 是否已成功升级,请尝试以下一些命令:
sudo virtualenv --version
输出:15.0.3echo $PYTHONPATH
输出:[空白]python -c 'import pkg_resources; print(pkg_resources.__file__)'
输出:~/.local/lib/python2.7/site-packages/pkg_resources/__init__.pycpython -c 'import sys; print(sys.path)'
输出:['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '~/.local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/dist-packages', '/opt/projects/myproject-google/myproject', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat']ls /opt/projects/myproject-google/venv/lib/python2.7/site-packages
输出:
easy_install.py pip pkg_resources setuptools-27.2.0.dist-info wheel-0.30.0a0.dist-info
easy_install.pyc pip-8.1.2.dist-info setuptools wheelpython -c 'from cryptography.hazmat.backends import default_backend; print(default_backend())'
输出:<cryptography.hazmat.backends.multibackend.MultiBackend object at 0x7ff83a838d50>/opt/projects/myproject-google/venv/bin/python -c 'from cryptography.hazmat.backends import default_backend; print(default_backend())'
输出
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named cryptography.hazmat.backends
/opt/projects/myproject-google/venv/bin/python -c "import pkg_resources; print(pkg_resources.__file__)"
输出:/opt/projects/myproject-google/venv/local/lib/python2.7/site-packages/pkg_resources/__init__.pyc参考链接: https: //github.com/pyca/cryptography/issues/3149
这些步骤使用更新版本的加密包和安装工具完全解决了属性入口点问题。
更新自 2016 年 9 月 15 日起,密码学团队再次添加了支持旧软件包的解决方法。(参考链接:https://github.com/pyca/cryptography/issues/3150)
| 归档时间: |
|
| 查看次数: |
680 次 |
| 最近记录: |