gpt4 book ai didi

python - 在 python 2.7.10、Mac OSX 下机械化的 SSLv3 握手失败

转载 作者:太空宇宙 更新时间:2023-11-03 13:38:21 25 4
gpt4 key购买 nike

我正在使用 mechanize 以进入网站。虽然能够在我 friend 的计算机(其操作系统是 Linux)上运行代码,但我面临以下握手失败警报:

urllib2.URLError: <urlopen error [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:590)>

我正在使用以下代码:

import mechanize
from bs4 import BeautifulSoup
import xlwt
import time
import unicodedata

br = mechanize.Browser()
br.set_handle_robots(False)
br.set_handle_equiv(False)
br.addheaders = [('User-agent', 'Chrome')]
page = br.open('https://....')

最佳答案

默认情况下禁用 SSLv3,因为它完全损坏。如果可能,请勿使用它。

Note: If you find that when certain older clients or servers attempt to connect with a SSLContext created by this function that they get an error stating “Protocol or cipher suite mismatch”, it may be that they only support SSL3.0 which this function excludes using the OP_NO_SSLv3. SSL3.0 is widely considered to be completely broken. If you still wish to continue to use this function but still allow SSL 3.0 connections you can re-enable them using:

ctx = ssl.create_default_context(Purpose.CLIENT_AUTH)
ctx.options &= ~ssl.OP_NO_SSLv3

这是这里的第二条注释:https://docs.python.org/2/library/ssl.html#ssl.create_default_context .

您需要以某种方式将配置的 SSLContext 传递给 mechanize

关于python - 在 python 2.7.10、Mac OSX 下机械化的 SSLv3 握手失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32734163/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com