Mark Harrison
Mark Harrison

Reputation: 304434

Python: How can I tell if my python has SSL?

How can I tell if my source-built python has SSL enabled? either

Context:

Upvotes: 18

Views: 16980

Answers (1)

Burhan Khalid
Burhan Khalid

Reputation: 174624

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

$ openssl version
OpenSSL 1.0.2g-fips  1 Mar 2016

You can get all sorts of information from version, for example, the directory where its stored:

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

As far as Python goes, I'm not sure how you can tell before running configure (maybe check the contents of config.log?) but once Python is installed; simply parse the output of ssl.OPENSSL_VERSION, like this:

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

For even more information, have a play with the sysconfig module, for example:

$ 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'

Upvotes: 28

Related Questions