如何用SSL在RHEL上编译python3?无法导入SSL [英] How to compile python3 on RHEL with SSL? SSL cannot be imported

查看:28
本文介绍了如何用SSL在RHEL上编译python3?无法导入SSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在RHEL上编译PYTHON,因为我当前的PYTHON使用的是旧的1.0.2k SSL版本。

(test_env) [brad@reason tlscheck]$ python3 --version
Python 3.9.3
(test_env) [brad@reason tlscheck]$ python3 -c "import ssl; print(ssl.OPENSSL_VERSION)"
OpenSSL 1.0.2k-fips  26 Jan 2017
(test_env) [brad@reason tlscheck]$ openssl version
OpenSSL 1.1.1l  24 Aug 2021

我认为问题在于,当我编译3.9.3时,我还没有更新我的OpenSSL版本。自那以后,我更新了我的OpenSSL,需要将其与Python一起使用。因此,我已经下载了最新的python3.10,但在make阶段,我得到了一个错误,它不会使用SSL生成。I以下消息:

Following modules built successfully but were removed because they could not be imported:
_hashlib              _ssl                                     


Could not build the ssl module!
Python requires a OpenSSL 1.1.1 or newer

这是尝试编译的完整日志: https://pastebin.com/36EntpFz

当我使用@Tony-yip提到的配置选项时,我在配置中得到以下内容。

checking for openssl/ssl.h in /etc/ssl... no
checking whether compiling and linking against OpenSSL works... no

我正在使用:

确定我的OpenSSL位置
[brad@reason Python-3.10.0]$ openssl version -d
OPENSSLDIR: "/etc/ssl"

要进行配置,我使用:

./configure --with-openssl="/etc/ssl"

当我查找ssl.h时,我在/usr/include/openssl中找到它。因此,我将此目录链接到/etc/ssl中的lib,但没有帮助。

[brad@reason Python-3.10.0]$ ls -l /etc/ssl
total 40
lrwxrwxrwx 1 root root    16 Jul 16  2020 certs -> ../pki/tls/certs
-rw-r--r-- 1 root root   412 Oct 12 02:53 ct_log_list.cnf
-rw-r--r-- 1 root root   412 Oct 12 02:53 ct_log_list.cnf.dist
lrwxrwxrwx 1 root root    20 Oct 18 10:22 lib -> /usr/include/openssl
drwxr-xr-x 2 root root  4096 Oct 12 02:53 misc
-rw-r--r-- 1 root root 10909 Oct 12 02:53 openssl.cnf
-rw-r--r-- 1 root root 10909 Oct 12 02:53 openssl.cnf.dist
drwxr-xr-x 2 root root  4096 Oct 12 02:53 private
[brad@reason Python-3.10.0]$ sudo find / -name ssl.h | grep include
find: ‘/tmp/.mount_jetbraAJFEnl’: Permission denied
/home/brad/Downloads/freerdp-2.0.0-rc4/winpr/include/winpr/ssl.h
/home/brad/Downloads/FreeRDP/winpr/include/winpr/ssl.h
/home/brad/Development/tlscheck/openssl-1.1.1l/include/openssl/ssl.h
/usr/include/openssl/ssl.h
/var/lib/docker/overlay2/23e6f3c164ec8939352891c99393669df4ed6e66da1e04ce84616073f08c6051/diff/usr/include/openssl/ssl.h
/var/lib/flatpak/runtime/org.freedesktop.Sdk/x86_64/18.08/c8075e929daaffcbe5c78c9e87c0f0463d75e90d2b59c92355fa486e79c7d0e3/files/include/nss/ssl.h
/var/lib/flatpak/runtime/org.freedesktop.Sdk/x86_64/18.08/c8075e929daaffcbe5c78c9e87c0f0463d75e90d2b59c92355fa486e79c7d0e3/files/include/openssl/ssl.h
find: ‘/run/user/1000/gvfs’: Permission denied

这可能是无关的信息,但我的libssl.so在这里:

[brad@reason Python-3.10.0]$ ls /usr/lib64 | grep ssl
libevent_openssl-2.0.so.5
libevent_openssl-2.0.so.5.1.9
libssl3.so
libssl.so
libssl.so.10
libssl.so.1.0.2k
openssl

关于make不能包含SSL的任何想法,请让我知道。谢谢。

推荐答案

遇到了一个非常类似的问题,openssl无法工作,并在centos 7上出现了与python3.10相同的错误。 下载OpenSSL解包,然后转到该目录

./config --prefix=/usr/local/custom-openssl --openssldir=/etc/ssl
make -j1 depend
make -j8
make install_sw

然后转到python源文件,将其解压缩并在目录中运行

./configure -C --with-openssl=/usr/local/custom-openssl --with-openssl-rpath=auto --prefix=/usr/local/python-3.version
make -j8
make altinstall

另请参阅https://docs.python.org/3/using/unix.html上的自定义OpenSSL。

这篇关于如何用SSL在RHEL上编译python3?无法导入SSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆