[英]Python: How can I tell if my python has SSL?
How can I tell if my source-built python has SSL enabled?如何判断我的源代码构建的 python 是否启用了 SSL? either
要么
Context:背景:
If all you want to do is figure out if openssl
is installed, you can parse the output of openssl version
:如果您只想确定是否安装了
openssl
,您可以解析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:您可以从
version
获取各种信息,例如,其存储目录:
$ 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;就 Python 而言,我不确定在运行 configure 之前如何判断(也许检查
config.log
的内容?)但是一旦安装了 Python; simply parse the output of ssl.OPENSSL_VERSION
, like this:只需解析
ssl.OPENSSL_VERSION
的输出,如下所示:
$ 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:有关更多信息,请使用
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'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.