OpenSSL 1.1.1g / Python 3.9 安裝、升級筆記
2025-04-30
僅記錄一次升級過程
因 urllib3 不支援舊的openssl,必需安裝新的 openssl/python 3.9:
ImportError: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2k-fips 26 Jan 2017'. See: https://github.com/urllib3/urllib3/issues/2168
安裝 openssl 1.1.1g
wget https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1g/openssl-1.1.1g.tar.gz
zcat openssl-1.1.1g.tar.gz | tar xfv -
cd openssl-1.1.1g
./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl shared zlib
make
make install
確認安裝後的版本
/usr/local/openssl/bin/openssl version
OpenSSL 1.1.1g 21 Apr 2020
執行 /usr/local/openssl/bin/openssl 若出現:
error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: No such file or directory
or
error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: No such file or directory
使用這3個命令,建立連結:
ln -s /usr/local/openssl/lib/libssl.so.1.1 /lib/libssl.so.1.1
ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /lib/libcrypto.so.1.1
ldconfig
安裝 Python-3.9.22
wget https://www.python.org/ftp/python/3.9.22/Python-3.9.22.tgz
zcat Python-3.9.22.tgz | tar xfv -
cd Python-3.9.22
./configure --with-openssl=/usr/local/openssl --enable-optimizations
make
make install
確認 python 3.9 使用哪個 openssl 版本?
$ /usr/local/bin/python3.9 -c "import ssl; print(ssl.OPENSSL_VERSION)"
OpenSSL 1.1.1zb 11 Feb 2025
留言