我目前正在使用pyOpenssl,它使用由系统安装的openssl 1.0.1f
。现在我从源代码安装openssl 1.0.1j
,并将新的版本库路径设置为LD_LIBRARY_PATH
,此时,当我运行py文件时,它会产生错误:
File "sslcert.py", line 5, in <module>
from OpenSSL import SSL, _util, crypto
...
File "/usr/local/lib/python2.7/dist-packages/cffi-0.8.6-py2.7-linux-x86_64.egg/cffi/vengine_cpy.py", line 149, in load_library
raise ffiplatform.VerificationError(error)
cffi.ffiplatform.VerificationError:
importing '/usr/local/lib/python2.7/dist-packages/cryptography-0.6.1-py2.7-linux-x86_64.egg/cryptography/_Cryptography_cffi_36a40ff0x2bad1bae.so':
/usr/local/lib/python2.7/dist-packages/cryptography-0.6.1-py2.7-linux-x86_64.egg/cryptography/_Cryptography_cffi_36a40ff0x2bad1bae.so:
symbol EC_GFp_nistp521_method, version OPENSSL_1.0.1 not defined in file libcrypto.so.1.0.0 with link time reference
我很想使用pyOpenssl的最新openssl库,如何解决这个问题?
答案 0 :(得分:4)
您可能需要针对较新版本的OpenSSL重新编译cryptography。
确保您也安装OpenSSL的开发标题,然后重建(可能最简单的方法是重新安装)加密。
升级OpenSSL的方式因您的平台而异。在Debian派生的系统上,这可能类似于apt-get install libssl-dev
(这将为您提供库和开发头文件)。在RedHat派生的系统上,它可能更像yum install libssl-devel
。
您可能需要调查virtualenv的使用,以使新构建的版本与已安装的版本分开。
拥有virtualenv后,您可以使用pip安装加密:
path/to/virtualenv/bin/pip install cryptography
或者您可以升级现有安装:
path/to/virtualenv/bin/pip install --upgrade cryptography
另请注意加密项目now ships manylinux1 wheels。这些是二进制包,包括所有依赖项 - 包括OpenSSL。因此,如果您使用的是可以使用 manylinux1 滚轮的平台,则无需单独安装OpenSSL或其开发标头。