5

我目前正在使用pyOpenssl,它使用1.0.1f由系统安装的 openssl。现在我1.0.1j从源代码安装openssl,并将新版本库路径设置为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 库,如何解决这个问题?

4

1 回答 1

5

您可能需要针对较新版本的 OpenSSL重新编译密码学。

确保你也安装了 OpenSSL 的开发头文件,然后重建(也许最容易通过重新安装)cryptography

您升级 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

另请注意,密码学项目现在提供manylinux1轮子。这些是包含所有依赖项的二进制包 - 包括 OpenSSL。因此,如果您在一个可以使用manylinux1轮子的平台上,则不需要单独的 OS 安装 OpenSSL 或其开发头文件。

于 2015-01-22T11:27:50.530 回答