无法使用urlib2通过代理发送HTTPS请求

2024-04-23 15:24:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图创建一个Python脚本,通过代理发送HTTPS请求(确切地说是Burp),但是它总是失败

ssl.CertificateError: hostname 'example.com:443' doesn't match u'example.com'

下面是我代码的缩写:

^{pr2}$

所以看起来Python认为Python(ssl.CertificateError是Python错误,而不是OpenSSL错误)有端口问题,或者其中一个地址是Unicode格式的。对我来说都没有意义。有什么建议吗?在


Tags: 代码https脚本comssl代理examplematch
1条回答
网友
1楼 · 发布于 2024-04-23 15:24:24

试试这个代码。我用了burp

测试.py

import urllib2

opener = urllib2.build_opener(
                urllib2.HTTPHandler(),
                urllib2.HTTPSHandler(),
                urllib2.ProxyHandler({'https': 'localhost:8080'}))
urllib2.install_opener(opener)
print opener.open( 'https://example.com', 'data' ).read()

打嗝配置

enter image description here


演示

enter image description here

相关问题 更多 >