Python: How can I find out if my python has SSL?

How can I find out if the built-in SSL source code is included in Python? or

  • after running configure, but before compiling (best).
  • after compilation when i can run python.

Context:

  • a script that populates an empty Linux field.
  • A prerequisite is installing openssl so that Python can execute https.
  • tries to determine if this precondition is being met.
+4
source share
1 answer

If all you want to do is figure out if it is installed openssl, you can parse the output openssl version:

$ openssl version
OpenSSL 1.0.2g-fips  1 Mar 2016

version, , , :

$ openssl version -d
OPENSSLDIR: "/usr/lib/ssl"

Python, , configure (, config.log?), Python; ssl.OPENSSL_VERSION, :

$ python -c "import ssl; print(ssl.OPENSSL_VERSION)"
OpenSSL 1.0.2g-fips  1 Mar 2016

, sysconfig, :

$ python -c "import sysconfig; print(sysconfig.get_config_var('CONFIG_ARGS'))"
'--enable-shared' '--prefix=/usr' '--enable-ipv6' '--enable-unicode=ucs4' '--with-dbmliborder=bdb:gdbm' '--with-system-expat' '--with-computed-gotos' '--with-system-ffi' '--with-fpectl' 'CC=x86_64-linux-gnu-gcc' 'CFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security ' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro'
+8

All Articles