neo*_*k23 21 python ssl openssl redhat
我正在尝试在 RHEL 上编译 python,因为我当前的 python 使用的是旧的 1.0.2k ssl 版本。
\n(test_env) [brad@reason tlscheck]$ python3 --version\nPython 3.9.3\n(test_env) [brad@reason tlscheck]$ python3 -c "import ssl; print(ssl.OPENSSL_VERSION)"\nOpenSSL 1.0.2k-fips 26 Jan 2017\n(test_env) [brad@reason tlscheck]$ openssl version\nOpenSSL 1.1.1l 24 Aug 2021\nRun Code Online (Sandbox Code Playgroud)\n我认为问题是当我编译 3.9.3 时,我没有更新我的 OpenSSL 版本。我已经更新了我的 OpenSSL 并需要将它与 python 一起使用。所以我下载了最新的python 3.10,但在make阶段我收到一个错误,它不会用ssl制作。我的消息如下:
\nFollowing modules built successfully but were removed because they could not be imported:\n_hashlib _ssl \n\n\nCould not build the ssl module!\nPython requires a OpenSSL 1.1.1 or newer\nRun Code Online (Sandbox Code Playgroud)\n这是尝试编译的完整日志:\n https://pastebin.com/36EntpFz
\n当我使用 @tony-yip 提到的配置选项时,我在配置中得到以下内容。
\nchecking for openssl/ssl.h in /etc/ssl... no\nchecking whether compiling and linking against OpenSSL works... no\nRun Code Online (Sandbox Code Playgroud)\n我正在确定我的 openssl 位置:
\n[brad@reason Python-3.10.0]$ openssl version -d\nOPENSSLDIR: "/etc/ssl"\nRun Code Online (Sandbox Code Playgroud)\n要配置,我正在使用:
\n./configure --with-openssl="/etc/ssl"\nRun Code Online (Sandbox Code Playgroud)\n当我查找 ssl.h 时,我在/usr/include/openssl. 所以我将此目录链接到 lib in /etc/ssl,但没有帮助。
[brad@reason Python-3.10.0]$ ls -l /etc/ssl\ntotal 40\nlrwxrwxrwx 1 root root 16 Jul 16 2020 certs -> ../pki/tls/certs\n-rw-r--r-- 1 root root 412 Oct 12 02:53 ct_log_list.cnf\n-rw-r--r-- 1 root root 412 Oct 12 02:53 ct_log_list.cnf.dist\nlrwxrwxrwx 1 root root 20 Oct 18 10:22 lib -> /usr/include/openssl\ndrwxr-xr-x 2 root root 4096 Oct 12 02:53 misc\n-rw-r--r-- 1 root root 10909 Oct 12 02:53 openssl.cnf\n-rw-r--r-- 1 root root 10909 Oct 12 02:53 openssl.cnf.dist\ndrwxr-xr-x 2 root root 4096 Oct 12 02:53 private\n[brad@reason Python-3.10.0]$ sudo find / -name ssl.h | grep include\nfind: \xe2\x80\x98/tmp/.mount_jetbraAJFEnl\xe2\x80\x99: Permission denied\n/home/brad/Downloads/freerdp-2.0.0-rc4/winpr/include/winpr/ssl.h\n/home/brad/Downloads/FreeRDP/winpr/include/winpr/ssl.h\n/home/brad/Development/tlscheck/openssl-1.1.1l/include/openssl/ssl.h\n/usr/include/openssl/ssl.h\n/var/lib/docker/overlay2/23e6f3c164ec8939352891c99393669df4ed6e66da1e04ce84616073f08c6051/diff/usr/include/openssl/ssl.h\n/var/lib/flatpak/runtime/org.freedesktop.Sdk/x86_64/18.08/c8075e929daaffcbe5c78c9e87c0f0463d75e90d2b59c92355fa486e79c7d0e3/files/include/nss/ssl.h\n/var/lib/flatpak/runtime/org.freedesktop.Sdk/x86_64/18.08/c8075e929daaffcbe5c78c9e87c0f0463d75e90d2b59c92355fa486e79c7d0e3/files/include/openssl/ssl.h\nfind: \xe2\x80\x98/run/user/1000/gvfs\xe2\x80\x99: Permission denied\nRun Code Online (Sandbox Code Playgroud)\n这可能是无关的信息,但我的 libssl.so 在这里:
\n[brad@reason Python-3.10.0]$ ls /usr/lib64 | grep ssl\nlibevent_openssl-2.0.so.5\nlibevent_openssl-2.0.so.5.1.9\nlibssl3.so\nlibssl.so\nlibssl.so.10\nlibssl.so.1.0.2k\nopenssl\nRun Code Online (Sandbox Code Playgroud)\n关于为什么 make 无法包含 ssl 的任何想法,请告诉我。谢谢。
\nkar*_*gen 18
有一个非常相似的问题,openssl 无法工作,并在 centos 7 上使用 python 3.10 给出相同的错误。下载 openssl unpack 然后转到该目录
./config --prefix=/usr/local/custom-openssl --openssldir=/etc/ssl
make -j1 depend
make -j8
make install_sw
Run Code Online (Sandbox Code Playgroud)
然后去python源码解压并在目录下运行
./configure -C --with-openssl=/usr/local/custom-openssl --with-openssl-rpath=auto --prefix=/usr/local/python-3.version
make -j8
make altinstall
Run Code Online (Sandbox Code Playgroud)
另请参阅https://docs.python.org/3/using/unix.html上的自定义 OpenSSL 。
小智 17
这非常有帮助,谢谢!令我震惊的是无法pip在 venv 中运行/更新,因此除了弄清楚如何让 OpenSSL 工作之外,没有太多其他选择。
截至本周(2021 年 12 月 21 日),在我的环境 ( CentOS Linux release 7.9.2009 (Core)) 中,我能够快捷地执行部分操作。
从 EPEL,安装openssl11,(是的,还有openssl11-devel);为了正确设置 Python 3.10,我需要创建“OpenSSL 目录”,方法如下:
mkdir /usr/local/openssl11
Run Code Online (Sandbox Code Playgroud)
然后为(新安装的)需求设置符号链接:
cd /usr/local/openssl11
ln -s /usr/lib64/openssl11 lib
ln -s /usr/include/openssl11 include
Run Code Online (Sandbox Code Playgroud)
最后,将此位置提供给configure脚本:
./configure --with-openssl=/usr/local/openssl11
Run Code Online (Sandbox Code Playgroud)
感谢您对如何以及为什么这一切都是必要的真正有用的解释。希望这对其他人有帮助...
正如输出所示,您需要指向 openssl11。我发现最简单的方法是更改configure python 3.10 源代码目录中的文件:
$ sed -i 's/PKG_CONFIG openssl /PKG_CONFIG openssl11 /g' configure
$ sudo ./configure --enable-optimizations
.
.
checking whether compiling and linking against OpenSSL works... yes
.
Run Code Online (Sandbox Code Playgroud)
然后您可以按照@CristiFati的建议进行操作,以便在安装之前检查其配置是否正确:
$ ./python -c "import sys, ssl; print(\"{:s}\n{:s}\".format(sys.version, ssl.OPENSSL_VERSION))"
3.10.0 (default, Nov 29 2021, 17:48:34) [GCC 7.3.1 20180712 (Red Hat 7.3.1-13)]
OpenSSL 1.1.1g FIPS 21 Apr 2020
Run Code Online (Sandbox Code Playgroud)
小智 0
Python 将使用捆绑的 ssl(有时已经过时)。为了随后使用 OpenSSL,请在运行 ./configure 时添加 OpenSSL 标志。有关详细信息,请运行./configure --help以获取更多选项。
--with-openssl=DIR root of the OpenSSL directory
--with-openssl-rpath=[DIR|auto|no]
Set runtime library directory (rpath) for OpenSSL
libraries, no (default): don't set rpath, auto:
auto-detect rpath from --with-openssl and
pkg-config, DIR: set an explicit rpath
--with-ssl-default-suites=[python|openssl|STRING]
override default cipher suites string, python: use
Python's preferred selection (default), openssl:
leave OpenSSL's defaults untouched, STRING: use a
custom string, python and STRING also set TLS 1.2 as
minimum TLS version
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18959 次 |
| 最近记录: |