PythonがアップグレードされたOpenSSLバージョンを認識しないのはなぜですか?

PythonがアップグレードされたOpenSSLバージョンを認識しないのはなぜですか?

CentOS 7にPython 3.7をインストールし、Pythonで使用されるSSLパッケージをアップグレードしようとしています。 opensslをアップグレードしましたが、このバージョンがあります...

(venv) [rails@server Python-3.7.0]$ openssl version -a
OpenSSL 1.1.1g  21 Apr 2020
built on: Thu May  7 19:18:59 2020 UTC
platform: linux-x86_64
options:  bn(64,64) rc4(16x,int) des(int) idea(int) blowfish(ptr) 
compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall -O3 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DZLIB -DNDEBUG
OPENSSLDIR: "/usr/local/openssl"
ENGINESDIR: "/usr/local/openssl/lib/engines-1.1"
Seeding source: os-specific

Python 3.7のソースコードをダウンロードし、Modules / Setup.distを次のように編集しました。

# Socket module helper for socket(2)
_socket socketmodule.c

# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL=/usr/local/openssl
_ssl _ssl.c \
        -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
        -L$(SSL)/lib -lssl -lcrypto

このように設定してインストールしました

./configure CPPFLAGS="-I/usr/local/openssl/include" LDFLAGS="-L/usr/local/openssl/lib"
make
make install

makeが正常に完了したようですが、次の警告が表示されます。

...
Python build finished successfully!
The necessary bits to build these optional modules were not found:
_lzma                 _tkinter              _uuid              
To find the necessary bits, look in setup.py in detect_modules() for the module's name.


The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc                  atexit                pwd                
time                                                           

running build_scripts
copying and adjusting /tmp/Python-3.7.0/Tools/scripts/pydoc3 -> build/scripts-3.7
copying and adjusting /tmp/Python-3.7.0/Tools/scripts/idle3 -> build/scripts-3.7
copying and adjusting /tmp/Python-3.7.0/Tools/scripts/2to3 -> build/scripts-3.7
copying and adjusting /tmp/Python-3.7.0/Tools/scripts/pyvenv -> build/scripts-3.7
changing mode of build/scripts-3.7/pydoc3 from 664 to 775
changing mode of build/scripts-3.7/idle3 from 664 to 775
changing mode of build/scripts-3.7/2to3 from 664 to 775
changing mode of build/scripts-3.7/pyvenv from 664 to 775
renaming build/scripts-3.7/pydoc3 to build/scripts-3.7/pydoc3.7
renaming build/scripts-3.7/idle3 to build/scripts-3.7/idle3.7
renaming build/scripts-3.7/2to3 to build/scripts-3.7/2to3-3.7
renaming build/scripts-3.7/pyvenv to build/scripts-3.7/pyvenv-3.7
(venv) [rails@server Python-3.7.0]$ 

しかし、Pythonを実行すると、まだ古いバージョンが表示されます。

[rails@server Python-3.7.0]$ python3 -c "import ssl; print(ssl.OPENSSL_VERSION)"
OpenSSL 1.0.2k-fips  26 Jan 2017

Pythonに正しいopensslパッケージを認識させるには、どうすればよいですか?

ベストアンサー1

おすすめ記事