Python 请求给我“错误握手”错误

2024-02-04

使用Pythonrequests http://docs.python-requests.org/en/master/像这样

import requests;
requests.get('https://internal.site.no')

给我一个错误many https://stackoverflow.com/questions/34085552/sslerror-bad-handshake-python-requests have https://stackoverflow.com/questions/37009692/ssl-error-bad-handshake had https://stackoverflow.com/questions/40004748/how-to-fix-bad-handshake-sslerrors-when-utilizing-python-requests;

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

然而,他们建议的缺失软件包都不起作用。均匀设置verify=False给了我同样的错误。 Curl 在尝试访问同一站点时没有给出任何错误。

版本:

  • 高山3.4
  • 请求 2.12.1(适用于 2.11.1)
  • OpenSSL 1.0.2j 2016 年 9 月 26 日

最可能的错误是requests并且服务器无法协商要使用的密码。

检查curl使用了什么;

curl --verbose https://internal.site.no/

它会给你很多输出,但你正在寻找的是类似的东西SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256.

看看差异2.11.1至2.12.0 https://github.com/kennethreitz/requests/compare/v2.11.1...v2.12.0请求,显示了新版本的 urllib3(至版本 1.19)。也许这就是去除3des https://github.com/shazow/urllib3/commit/02c5d965d0f8c64b67c4067c9d650754ef644781#diff-8b6e87f6b5a8da0b15b37afaded9ac60它在这儿咬你吗?

如果您检查您的curl --verbose ...输出使用密码对抗this https://testssl.sh/openssl-rfc.mappping.html有用的密码名称映射列表。您可以尝试添加openssl名字的名字是什么requests接受,例如(您可以在应用程序/脚本的开头执行此操作):

import requests
requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS += ':ADH-AES128-SHA256'

如果curl显示你正在使用TLS_DH_anon_WITH_AES_128_CBC_SHA256(举个例子)。

另一个方便的技巧是使用 nmap 脚本ssl 枚举密码 https://nmap.org/nsedoc/scripts/ssl-enum-ciphers.html, 像这样:

nmap --script ssl-enum-ciphers -p 443 internal.site.no

获取它发现的受支持密码的列表(注意,脚本可能很吵)...

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Python 请求给我“错误握手”错误 的相关文章

随机推荐