强制机械化使用SSLv3
作者:互联网
您将如何强制mechanize将SSLv3用于需要它的HTTPS URL?如果我尝试对所有仅SSLv3的URL使用机械化,则会收到错误消息:
URLError: <urlopen error [Errno 1] _ssl.c:504: error:140773E8:SSL routines:SSL23_GET_SERVER_HELLO:reason(1000)>
解决方法:
肮脏的答案…不需要修补.
import ssl
from ssl import PROTOCOL_SSLv23, PROTOCOL_SSLv3, CERT_NONE, SSLSocket
def monkey_wrap_socket(sock, keyfile=None, certfile=None,
server_side=False, cert_reqs=CERT_NONE,
ssl_version=PROTOCOL_SSLv23, ca_certs=None,
do_handshake_on_connect=True,
suppress_ragged_eofs=True, ciphers=None):
ssl_version=PROTOCOL_SSLv3
return SSLSocket(sock, keyfile=keyfile, certfile=certfile,
server_side=server_side, cert_reqs=cert_reqs,
ssl_version=ssl_version, ca_certs=ca_certs,
do_handshake_on_connect=do_handshake_on_connect,
suppress_ragged_eofs=suppress_ragged_eofs,
ciphers=ciphers)
ssl.wrap_socket = monkey_wrap_socket
…在您的代码之前.
标签:ssl,mechanize-python,mechanize,python 来源: https://codeday.me/bug/20191123/2063984.html