【问题标题】:python-request with OpenSSL on macOS Sierra在 macOS Sierra 上使用 OpenSSL 的 python 请求
【发布时间】:2017-05-25 08:33:31
【问题描述】:

大家好
我在尝试使用python请求包时遇到了一个问题,您可能会发现错误如下:

文件“/Library/Python/2.7/site-packages/requests/adapters.py”,第 512 行,在发送中
引发 SSLError(e, request=request)
requests.exceptions.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 警报握手失败 (_ssl.c:590)

然后我在终端中使用 brew 将 openssl 库更新为最新版本。

>brew update
>brew install openssl

但是,在将最新的 openssl 与

链接时
>brew link openssl -force

它出现了来自 macOS 的错误:

警告:拒绝链接:openssl 链接仅桶装 openssl 意味着您最终可能会链接到不安全的, 使用 Homebrew 的 openssl 标头时弃用了系统 OpenSSL。
相反,将完整的包含/库路径传递给您的编译器,例如:
-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib

我不知道在这种情况下该怎么做,除了获得我只想避免的 root 访问权限之外,几乎没有任何实用的解决方案。
谁能给我一些提示?我真的很感激。

顺便说一句,我的 macOS 版本是 Sierra 10.12.3。
我的 Mac 上没有安装 ms dotnet。请不要解决那个相关的答案。

【问题讨论】:

  • 您尝试访问的网址。如果它是您自己管理的内部服务器,请检查服务器上的 ssl 证书是否有效并正确构建。
  • @xrage 否 我试图访问外部网站上的公共 URL。我不认为这是 ssl 证书问题。
  • 如果您可以分享您遇到该问题的网址或类似网址。然后它在调试时会很有用。

标签: python macos ssl python-requests macos-sierra


【解决方案1】:

升级 pyOpenSSL 对我有用。

sudo pip install --upgrade pyOpenSSL 

如果系统提示您以下警告:

Cannot uninstall 'pyOpenSSL'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

你可以这样做:

sudo pip install --upgrade pyOpenSSL --ignore-installed pyOpenSSL

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-22
    • 2017-02-10
    • 1970-01-01
    • 1970-01-01
    • 2018-01-27
    • 1970-01-01
    • 2017-03-31
    • 2017-06-28
    相关资源
    最近更新 更多