在 macOs X Capitan 中为 python 3.5 更新 OpenSSL



我正在尝试更新在MacOS El Capitan上运行的Python 3.5的OpenSSL。我已通过以下命令安装了新版本:

brew install openssl

我在外壳上得到了以下内容:

A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl/certs
and run
  /usr/local/opt/openssl/bin/c_rehash
This formula is keg-only, which means it was not symlinked into /usr/local.
Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
LDFLAGS:  -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include
==> Summary
🍺  /usr/local/Cellar/openssl/1.0.2g: 1,678 files, 12.0M

然后,我检查外壳上的版本:

$ python -c "import ssl; print ssl.OPENSSL_VERSION"  
OpenSSL 0.9.8zh 14 Jan 2016  
$ openssl version  
OpenSSL 1.0.2o  27 Mar 2018  

OpenSSL似乎有两个版本,Python继续使用最旧的版本。我需要获取OpenSSL的更新版本来运行Python程序,但我不知道如何使Python使用最新版本。我也不知道如何使用使用brew安装新版本后提供的信息。
任何帮助将不胜感激!

我得到了这个问题的解决方案! 关键是Python 3.5适用于OpenSSL 0.9.8。解决方案是安装具有特定配置的Python 3.6.5,以包含"OpenSSL 1.0.2n 2017年12月7日"。

brew install openssl
brew link openssl --force  # if you need too
brew install python3  --with-brewed-openssl  # this brings Python 3.6.5, and not 3.5

最新更新