【发布时间】:2016-08-09 20:18:30
【问题描述】:
运行 openssl version 在 OS El Capitan 上返回标准 openssl,OpenSSL 0.9.8zh in /usr/bin/openssl。
我已经通过 brew brew install openssl 安装了最新版本。建议手动链接到/usr/local/bin/openssl 或运行brew link --force openssl 的各种帖子/文章。其他帖子说不要这样做,运行后者也给出了以下警告。
Warning: Refusing to link: openssl
Linking keg-only openssl means you may end up linking against the insecure,
deprecated system OpenSSL while using the headers from Homebrew's openssl.
Instead, pass the full include/library paths to your compiler e.g.:
-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib
我不确定这意味着什么。 :|
我还成功地符号链接到 brew 版本,所以which openssl 指向/usr/local/bin/openssl 而不是系统/usr/bin/openssl 版本,which openssl 也返回了最新版本,但是当我打开一个 python shell 时,里面在 virtualenv 之外运行 import ssl ssl.OPENSSL_VERSION 它返回了系统版本。
如何强制它在我的 python 代码中使用 brew 版本?
【问题讨论】:
-
问题是什么?参见 Stack Overflow 上的 Brew refusing to link openssl 和 Link: don't link /usr/local openssl Github 提交。
-
谢谢 jww,我已经相应地编辑了问题。我已经阅读了这些内容,您是否建议实施 Ben Collins .net 解决方案?
sudo install_name_tool -add_rpath...在 python 环境中我在哪里做这个? -
是的,您应该始终在 OS X 系统上使用 OpenSSL 的安装名称。我知道 OpenSSL 1.1.0 使用它们,但我不记得 OpenSSL 1.0.2 和更早版本。不过,这只是成功的一半。另一半是确保 Apache、Python 和 Ruby 等程序针对更新的 OpenSSL 进行编译和链接。为确保在编译时使用正确的库,您必须使用
-I和-L。为确保运行时链接器使用正确的 OpenSSL 库,使用了安装名称。
标签: python ssl openssl virtualenv homebrew