在centos5上用非系统Openssl编译python2.7.12

2024-09-28 21:31:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前正在尝试让python2.7.12在centos5主机上使用openssl1.0.2h进行编译。在

原因是我需要Paramiko 2在这个主机上运行,但是它不支持系统提供的OpenSSL版本0.9.8e-fips-rhel5 2008年7月1日。在

我在这里找到了一些很好的提示和提示,但似乎行不通。我现在把这个贴出来,希望有人能发现我做错了什么/遗漏了什么。在

对于OpenSSL设置,我完成了以下操作:

OPENSSL_ROOT="$HOME/.build/openssl-1.0.1e"
cd /tmp
curl http://www.openssl.org/source/openssl-1.0.2h.tar.gz | tar zxvf -
cd openssl-1.0.2.h
mkdir -p "$OPENSSL_ROOT"
./config no-hw --prefix="$OPENSSL_ROOT" --openssldir=...
make install

因为我不想用2.7.12替换系统安装的Python,所以我做了以下工作:

首先,我将/usr/local/lib添加到/etc/ld.so.conf公司然后运行ldconfig。在

之后我跑了:

^{pr2}$

这是我认为应该根据新版本的OpenSSL编译它,但是没有,正如您从这里的输出中看到的那样:

[root@an-host openssl-1.0.2h]# python2.7 -c "import ssl; print ssl.OPENSSL_VERSION"
OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008

我确信我运行的是最新编译的版本,因为这一点在这里得到了回应:

[root@an-host openssl-1.0.2h]# python2.7
Python 2.7.12 (default, Aug  1 2016, 11:46:42) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-55)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

我甚至已经用Yum删除了openssl-devel,但它似乎仍然不关心/编译1.0.2h

这让我现在有点生气,所以任何输入/反馈/帮助都非常感谢。在


Tags: 版本anhostsslcd原因roottar
1条回答
网友
1楼 · 发布于 2024-09-28 21:31:33

我想我试图复制太可爱的解决方案和混合搭配-整理和简化了一点,最终使它发挥作用。在

这是我这次所做的:

下载并安装OpenSSL

cd /tmp 
curl http://www.openssl.org/source/openssl-1.0.2h.tar.gz | tar zxvf - 
cd openssl-1.0.2.h 
./config shared  prefix=/usr/local/ 
make && make install

设置一些环境变量

^{pr2}$

下载并安装python2.7.12

wget http://python.org/ftp/python/2.7.12/Python-2.7.12.tar.xz
tar xf Python-2.7.12.tar.xz
cd Python-2.7.12
./configure  prefix=/usr/local/  enable-unicode=ucs4  enable-shared
make && make altinstall

现在它像预期的那样工作,显示了更新的OpenSSL版本。在

[root@an-host Python-2.7.12]# python2.7
Python 2.7.12 (default, Aug  1 2016, 14:48:09) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-55)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> print ssl.OPENSSL_VERSION
OpenSSL 1.0.2h  3 May 2016

然而,它仍然没有如预期的那样工作。:(运行程序时,我从Paramiko得到以下错误:

RuntimeError: You are linking against OpenSSL 0.9.8, which is no longer support by the OpenSSL project. You need to upgrade to a newer version of OpenSSL.

我找到的解决方案是通过运行卸载并重新安装密码。在

pip2.7 uninstall cryptography
pip2.7 install cryptography

在所有这些之后,它现在起作用了。在

相关问题 更多 >