【问题标题】:requests.exceptions.SSLErrorrequests.exceptions.SSLError
【发布时间】:2016-11-08 16:12:36
【问题描述】:

我有 fiddle.py 包含 4 行

import requests

url = "https://randomuser.me/api/"
locations = requests.get(url,verify=False).json()

print locations

当我运行它时,我不断得到

requests.exceptions.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 警报握手失败 (_ssl.c:590)


试试#1

设置verify=False

运行代码,同样的错误。


尝试#2

运行sudo pip install --upgrade requests

运行代码,同样的错误。


尝试#3

运行

sudo pip install --upgrade pip

sudo pip install requests[security]

运行代码,不同的错误。

requests.exceptions.SSLError: ("bad handshake: Error([('SSL routines', 'SSL23_GET_SERVER_HELLO', 'sslv3 alert handshake failure')],)",)


详情

  • Python 2.7.10
  • OpenSSL 0.9.8zh 2016 年 1 月 14 日
  • Mac OS X 10.11.6

如何调试?

【问题讨论】:

  • 我都试过了,是否需要重新启动我的 Mac 或终端?
  • 您找到解决此问题的方法了吗?我也面临同样的问题。

标签: python macos python-requests pyopenssl


【解决方案1】:

您想使用 OpenSSL 1.0.2 和 python 2.7.12。您可能还需要最新的 curl。

brew update
brew upgrade openssl
brew upgrade curl
brew upgrade python

python --version # make sure you have python 2.7.12
curl https://randomuser.me/api/ # to verify

【讨论】:

  • 你可能也需要--force-link。我不使用 Brew,所以我不确定这是否就是它的名称。但它经常出现在 Mac、Brew 和 OpenSSL 问题中。
  • 即使我的 python 现在是 2.7.12 - 我在运行 curl https://randomuser.me/api/ 时得到了这个 curl: (35) error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
  • 您还有什么建议吗?
  • @ihue: curl --version的输出是什么?
【解决方案2】:

我会确保它们在 https 的端口 443 上运行,如果在 Linux 上可以使用 dig +short example.com,您不会得到重定向你应该得到类似于ghs.googlehosted.com 的输出或在这种情况下重定向的url 我相信谷歌托管的网站将由于Web 应用程序防火墙而重定向。当我尝试访问从 requests.get(domain) 收到错误的 url 时,我被重定向到登录门户

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-02-21
    • 1970-01-01
    • 2016-10-27
    • 1970-01-01
    • 2016-01-29
    • 2016-11-26
    • 1970-01-01
    • 2017-02-05
    相关资源
    最近更新 更多