我们想在centos 7中升级OpenSSL但没有成功,原因可能是这样的。 通过 yum install openssl11 将 CentOS 7 升级到 OpenSSL 1.1.1
我开始知道 openssl11 是用于“现货”使用的。我们可以将 python / pyOpenssl 与 openssl11 链接起来吗? 如果可以请给我流程
我今天在尝试在 CentOS 7 上构建 Python 3.10 时遇到了这个问题,并在试图解决这个问题时发现了这个线程。就我而言,我只是尝试构建所有 Python,包括它默认尝试构建的 SSL 模块。接下来的内容可能适用于也可能不适用于自行构建 pyOpenSSL。
我发现配置脚本似乎被设计为与安装在 /usr/lib64 和 /usr/include 中正常位置的 OpenSSL 文件一起使用,或者安装在一个位置,您可以在命令行上使用以下命令指定--with-openssl 参数,在该参数下可以直接找到包含文件和库。 RHEL/CentOS 7 中的“openssl11-devel”软件包无法满足这些期望,据我所知,这无法在配置命令行上处理。
我发现解决这个问题的最简单方法就是更改脚本与其 pkg-config 查询一起使用的库名称,这样它就可以从 .pc 文件中获取正确的详细信息,幸运的是该文件位于 /usr 下的标准位置/lib64/pkgconfig 但名称不同。
我使用的方法恰好适用于 CentOS 7 上安装的 Python3.10.0,但不可否认它很脆弱,并且可能无法继续适用于其他版本。从源目录中:
sed -i 's/PKG_CONFIG openssl /PKG_CONFIG openssl11 /g' configure
完成上述操作后,我运行
./configure
。我在输出中看到:
检查针对 OpenSSL 的编译和链接是否有效...是的
...而不是我之前得到的“不”。
可能不相关——无论出于何种原因,我都无法在 CentOS 7 上使用 --enable-optimizations 进行编译。我收到“无法导入 runpy 模块”错误,因此我在没有它的情况下进行配置。
我必须在 CentOS 7 服务器中安装 Python 3.10.6,我发现这个邮件线程帮助我创建了 OpenSSL 1.1.1“现货”安装并在 Python 安装中使用它。
我决定全部安装在
/opt
,但你可以选择不同的位置。
# Install OpenSSL 1.1.1
cd /opt
curl https://ftp.openssl.org/source/old/1.1.1/openssl-1.1.1j.tar.gz --output openssl.tar.gz
tar xzf openssl.tar.gz
rm openssl.tar.gz
cd openssl-1.1.1j/
./config --prefix=/opt/openssl && make && make install
# Install Python 3.10.6
cd /opt
wget https://www.python.org/ftp/python/3.10.6/Python-3.10.6.tgz
tar xzf Python-3.10.6.tgz
cd Python-3.10.6
./configure --with-openssl=/opt/openssl
make
make altinstall
测试安装
python3.10 --version
# Output: Python 3.10.6
所以这是一个古老的问题,但在 2023 年如何做到这一点仍然不明显,所以我会发布我的答案。
我还需要在 RHEL 7 上安装 Python3.11.2,当然 Python 需要 OpenSSL 1.1.1+。
但是,我需要保持旧的现有 OpenSSL 安装完好无损 - 主要是因为我依赖于新版本中破坏的其他操作系统软件包(例如,
authconfig
)。
下面的方法对我有用。
安装软件包:
yum install openssl11 openssl11-devel
(我曾尝试从源代码下载和构建 OpenSSL,它适用于 Python,但破坏了我使用的其他操作系统软件包)
验证已安装的 OpenSSL 版本:
which openssl # prints /usr/bin/openssl
which openssl11 # prints /usr/bin/openssl11
openssl version # prints OpenSSL 1.0.2k-fips 26 Jan 2017
openssl11 version # prints OpenSSL 1.1.1k FIPS 25 Mar 2021
用于构建 Python 的
openssl11
二进制文件和库的位置位于此处:
which openssl # prints /usr/bin/openssl11
ls -l /lib64/openssl11 # prints symlinks to openssl 1.1.1k files in /lib64
然后我从源代码构建了Python 3.11.2。请注意,我的 RHEL7 上的 gcc 版本是 4.8.5,根据下面的评论,这可能会导致一些问题。我没有启用优化。
# ... first download and untar ...#
...
# Configure
# --enable-optimizations caused problems for me. YMMV
LDFLAGS="${LDFLAGS} -Wl,-rpath=/lib64/openssl11/" ./configure --with-openssl=/bin/openssl11
# Single-core build. Multithreading (-j option) caused problems.
make
# Install
make altinstall
ln -sf /usr/local/bin/python3.11 /usr/bin/python3
还不能发表评论,但我想扩展下面 Circle 的回应。使用 Fedora 28 并安装 Python 3.11.5
我运行了以下设置:
# Install OpenSSL 1.1.1
cd /opt
curl https://ftp.openssl.org/source/old/1.1.1/openssl-1.1.1j.tar.gz --output openssl.tar.gz
tar xzf openssl.tar.gz
rm openssl.tar.gz
cd openssl-1.1.1j/
./config --prefix=/opt/openssl && make && make install
# Install Python 3.10.6
cd /opt
wget https://www.python.org/ftp/python/3.10.6/Python-3.10.6.tgz
tar xzf Python-3.10.6.tgz
cd Python-3.10.6
./configure --with-openssl=/opt/openssl --with-openssl-rpath=auto
make
make altinstall