ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

使用Centos 5上的非系统Openssl编译Python 2.7.12

2019-08-24 03:51:33  阅读:375  来源: 互联网

标签:python linux compilation openssl centos5


我目前正试图在Centos 5主机上使用Openssl 1.0.2h编译Python 2.7.12.

原因是我需要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.

之后我跑了:

cd /tmp
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 CPPFLAGS="-I$OPENSSL_ROOT/include"  LDFLAGS="-L$OPENSSL_ROOT/lib"  --prefix=/usr/local --enable-unicode=ucs4 --enable-shared
make && make altinstall

这是我认为我已经针对新版本的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.

这让我有点生气,所以任何输入/反馈/帮助都非常感激.

解决方法:

我想我试着复制太可爱的解决方案并混合搭配 – 整理并简化了一下,最终让它发挥作用.

这就是我这次做的事情:

下载并安装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

设置一些环境变量

export LDFLAGS="-L/usr/local/lib/"
export LD_LIBRARY_PATH="/usr/local/lib/"
export CPPFLAGS="-I/usr/local/include -I/usr/local/include/openssl"

下载并安装Python 2.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.

我找到的解决方案是通过运行卸载并重新安装Cryptography位.

pip2.7 uninstall cryptography
pip2.7 install cryptography

毕竟 – 它现在有效.

标签:python,linux,compilation,openssl,centos5
来源: https://codeday.me/bug/20190824/1703672.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有