Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 Urllib2通过代理和信任不受信任的SSL证书_Python 2.7_Ssl_Proxy_Urllib2 - Fatal编程技术网

Python 2.7 Urllib2通过代理和信任不受信任的SSL证书

Python 2.7 Urllib2通过代理和信任不受信任的SSL证书,python-2.7,ssl,proxy,urllib2,Python 2.7,Ssl,Proxy,Urllib2,我读过各种帖子,比如: 等等,等等,但是,对我来说什么都不行。我想通过截取代理(Burp Suite Pro)代理一切,这样我就可以查看和编辑Python 2脚本发出的请求,但我不希望它在Burp CA证书无效时出错。我的代码: proxy={'http': '127.0.0.1:8081', 'https': '127.0.0.1:8081'} proxy_handler = urllib2.ProxyHandler(proxy) opener = urllib2.build_op

我读过各种帖子,比如:

等等,等等,但是,对我来说什么都不行。我想通过截取代理(Burp Suite Pro)代理一切,这样我就可以查看和编辑Python 2脚本发出的请求,但我不希望它在Burp CA证书无效时出错。我的代码:

proxy={'http': '127.0.0.1:8081', 'https': '127.0.0.1:8081'}
proxy_handler = urllib2.ProxyHandler(proxy)
opener = urllib2.build_opener(proxy_handler)
context = ssl._create_unverified_context()
opener.context = context
urllib2.install_opener(opener)

url_request = urllib2.Request("https://example.com")
response = opener.open(url_request)
也试过

import ssl
context = ssl.create_default_context()
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
我还尝试将Burp
cacert.der
文件复制到
/etc/pki/ca-trust/source/anchors/
并运行
更新ca-trust
。所有人都给出了错误

urllib2.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:727)>
urllib2.URLError:

我也有同样的问题