Python 3.12.1 build can not find the openssl libraries on RHEL9.3 host

openssl seems to be installed on the rhel9 server, but I am not able to find the shared dynamic library anywhere on the host. The command “openssl version” gives back - 3.0.7 and in the OPENSSL_LIBRARY path, I only see certs,openssl.cnf file. Does this mean, I need to download openssl packages separately to the host to make Python 3.12.1 work with openssl?
Is there any other way we can make Python to use default openssl from the host itself? Whats the recommended way ?

It would help if you gave a bit more detail. Are you building your own copy of Python? If so, did you install openssl-devel? Those contain the bits are needed to link to the system openssl, which as you’ve confirmed, is already present.

Thanks for the reply Mats. yes I made sure openssl-devel is already installed.

openssl-devel.i686 1:3.0.7-24.el9

I am trying to build my own copy of python using 3.12.1 version as Redhat 9.x host has default - python 3.9. I noticed it has openssl , but I believe its compiled in FIPS mode, so can not find the openssl headers files or .so dynamic shared files under /etc/pki/ssl. So i am not how to build python 3.12.1 so that it can link to openssl from the host’s default installation (.Configure in build process expects to give openssl directory which usually has those files).

So I tried to have custom openssl installation by downloading the source for same openssl 3.0.7 and followed the openssl build using the link : 2. Using Python on Unix platforms — Python 3.12.2 documentation

Now whats the recommended CPPFLAGS /LDFLAGS or ./Configure … options for building Python 3.12.1 ? I had tried with --enable-shared option along with linking custom openssl lib64 path to LDFLAGS. But urllib3 v2.x does not seem to work still with it.
I am not sure whether openssl 3.x ever work with python 3.12.1 or should I be downgrading to openssl 1.1.1 ? Also whats the best compatible versions which work well for cryptography + urllib3 for python 3.12.1? I highly appreciate the suggestions. thank you.

You are build a 32 bit version of python? Implied by the i686 package.
If you are building 64 bit that is the wrong openssl-devel package.

Sorry, I copied the wrong one -
Its actually 64 bit only
“Package openssl-devel-1:3.0.7-24.el9.x86_64 is already installed.”

FYI this is what .so etc are installed at run-time for openssl:

$ rpm -ql openssl-libs

If you have built your own openssl its likely that it installed into /usr/local not /usr.

Thanks for that info. I do see / etc files under /usr/lib64 (similar to what you pasted for 3.1.1). But when I add /usr/lib64 to LD_LIBRARY_PATH , python still did not work for openssl. Also i noticed the size of these files are different than the files which I built as custom by downloading the source from - possibly those .so files have newly added additional LDFLAGS (folders) ? When I built custom openssl package, it worked fine with python.
I am trying to figure out what I might have missed to make existing openssl installation work with python 3.12.1.

Have you looked at the pkgconfig files for openssl for what must be on the link line?

$ rpm -ql openssl-devel |grep pc

Oh and what I do when back porting to RHEL start with the Fedora SRPM, in this case python source RPM. Doubt it will just build, but it will have a working %build section that you can see how Fedota builds python.