So this is an old-ish question but it's still not obvious how to do this in 2023 so I'll post my answer.
I also needed to install Python3.11.2 on RHEL 7, and of course Python needs OpenSSL 1.1.1+.
However I needed to keep the older existing OpenSSL installation in-tact - mainly because I rely on other OS packages that break with the new version (for example, authconfig
).
The approach below worked for me.
Install packages:
yum install openssl11 openssl11-devel
(I had tried downloading and building OpenSSL from source which worked for Python but broke other OS packages I use)
Verify installed OpenSSL versions:
which openssl # prints /usr/bin/openssl
which openssl11 # prints /usr/bin/openssl11
openssl version # prints OpenSSL 1.0.2k-fips 26 Jan 2017
openssl11 version # prints OpenSSL 1.1.1k FIPS 25 Mar 2021
The location of the openssl11
binary and libraries for building Python are then here:
which openssl # prints /usr/bin/openssl11
ls -l /lib64/openssl11 # prints symlinks to openssl 1.1.1k files in /lib64
Then I built Python 3.11.2 from source. Note that gcc version was 4.8.5 on my RHEL7 and this may cause some problems per comments below. I was fine with not enabling optimisations.
# ... first download and untar ...#
...
# Configure
# --enable-optimizations caused problems for me. YMMV
LDFLAGS="${LDFLAGS} -Wl,-rpath=/lib64/openssl11/" ./configure --with-openssl=/bin/openssl11
# Single-core build. Multithreading (-j option) caused problems.
make
# Install
make altinstall
ln -sf /usr/local/bin/python3.11 /usr/bin/python3