該賞金到期in 4天。此問題的答案有資格獲得 100聲望獎勵。 neogeek23想引起更多人對這個問題的關注:
上周我試圖在 rhel 7.9 上編譯 python,我得到了一個建議,但我仍然遇到問題,我想提出這個問題,因為我確信它不再被審查以尋求答案。
我正在嘗試在 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 一起使用。所以我已經下載了最新的 python 3.10,但是在 make 階段我得到一個錯誤,它不會用 ssl 生成。我有以下訊息:
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. 所以我將此目錄鏈接到 lib in /etc/ssl,但沒有幫助。
[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 的任何想法,請告訴我。謝謝。
uj5u.com熱心網友回復:
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
uj5u.com熱心網友回復:
你可能已經這樣做了
如果我在你的位置,我會嘗試更新 apt-get 包:
sudo apt update
sudo apt upgrade
更新 apt 將自動更新 openSSL。如果它不起作用,您可以單獨更新 OpenSSL:
apt install openssl
然后從命令列生成新創建的自簽名證書:
openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365
該命令寫入一個新的證書cert.pem,其對應的私鑰 in key.pem,有效期為 365 天。有關此鏈接中證書的更多資訊,請查找“ Achieving an SSL A Grade ”標題。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/325604.html
