Python SSLError,sslv3 警报握手失败,用于 wallhaven.cc [英] Python SSLError, sslv3 alert handshake failure, for wallhaven.cc

查看:59
本文介绍了Python SSLError,sslv3 警报握手失败,用于 wallhaven.cc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Python 版本:3.5.2

Python Version: 3.5.2

操作系统:OS X 10.12

OS: OS X 10.12

OpenSSL 版本:OpenSSL 1.1.0b 2016 年 9 月 26 日

OpenSSL Version: OpenSSL 1.1.0b 26 Sep 2016

我正在尝试请求https://alpha.wallhaven.cc".

import urllib.request
init_page=urllib.request.urlopen("https://alpha.wallhaven.cc")

然后得到

ssl.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:645)

During handling of the above exception, another exception occurred:
...
urllib.error.URLError: <urlopen error [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:645)>

以下解决方案不起作用:

The following solutions don't work:

import requests.packages.urllib3.util.ssl_
requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS='ALL'

import ssl
ssl._create_default_https_context = ssl._create_unverified_context

import requests
print(requests.get("https://alpha.wallhaven.cc",verify=False))

或更改/APNSWrapper/connection.py 第 131 行:

or change /APNSWrapper/connection.py line 131:

ssl_version = self.ssl_module.PROTOCOL_SSLv3,

进入

ssl_version = self.ssl_module.PROTOCOL_TLSv1,

那有什么问题呢?如何解决?非常感谢!

Then what is the problem? How to solve it? Thanks a lot!

推荐答案

OpenSSL 版本:OpenSSL 1.1.0b 2016 年 9 月 26 日... sslv3 警报握手失败 (_ssl.c:645)>

OpenSSL Version: OpenSSL 1.1.0b 26 Sep 2016 ... sslv3 alert handshake failure (_ssl.c:645)>

我不怀疑您的系统上安装了 OpenSSL 1.1.0b,但我怀疑您的 Python 是否实际使用了该版本.通常 MacOS 安装了旧版本的 OpenSSL 0.9.8,除非 编译 python 以使用另一个openssl 将使用此版本,即使系统上某处安装了其他 OpenSSL 版本.要检查您的 python 使用的 OpenSSL 版本:

I do not doubt that you have OpenSSL 1.1.0b installed on your system but I doubt that this version is actually used by your python. Usually MacOS has the old version 0.9.8 of OpenSSL installed and unless one compiles python to use another openssl this version will be used, even if other OpenSSL versions are installed somewhere on the system. To check what version of OpenSSL is used by your python:

  import ssl
  print(ssl.OPENSSL_VERSION)

如果这显示 OpenSSL 1.1.0b... 我的假设是错误的,但如果这显示 0.9.8,我对以下论证是正确的:

If this shows OpenSSL 1.1.0b... I'm wrong in my assumption but if this shows 0.9.8 I'm right with the following argumentation:

  • 握手失败表示与证书验证无关的问题.
  • 查看 SSLLabs 报告 我可以看到服务器只支持 ECDHE 密码.
  • OpenSSL 0.9.8 版不支持 ECDHE 密码
  • 因此客户端和服务器之间没有共享密码,握手失败
  • handshake failure indicates a problem which is not related to certificate validation.
  • Looking at the SSLLabs report I can see that the server only suppors ECDHE ciphers.
  • ECDHE ciphers are not support by OpenSSL version 0.9.8
  • therefore there are no shared ciphers between client and server and the handshake fails

这篇关于Python SSLError,sslv3 警报握手失败,用于 wallhaven.cc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆