使用CA5证书和http证书身份验证的代理身份验证

时间:2018-09-09 05:47:49

标签: python urllib3

我是Python的新手,它试图读取和解析应用程序https url的日志。我的组织有代理设置。我可以使用basic_auth并通过以下代码通过CA5证书提供&&来连接http网址     导入urllib3

from urllib3 import ProxyManager, make_headers
# default_headers = make_headers(proxy_basic_auth='<username>:<password>')
# http = ProxyManager("http://<proxy_server>:<port>/", headers=default_headers)
http = ProxyManager("http://<proxy_server>:<port>/",cert_reqs='CERT_REQUIRED',ca_certs='<Windows path to .cer>')
r = http.request('GET','http://google.com')
print(r.data)

.pem证书已在Windows系统上另存为.cer。 这是作为例外和返回谷歌数据。 现在,虽然尝试使用下面的HTTPS网址使用

r = http.request('GET','https://google.com',verify='<same as above i.e. Windows path to .cer>')

由于以下错误而失败,

.
.
OSError: Tunnel connection failed: 502 notresolvable
.
.
.
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='google.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)'),))

由于日志文件不断更新,可能需要对其进行流式处理;我们对此表示赞赏。

Windows 7 上使用 Python 3.6.0 | Anaconda 4.3.1(64位)

0 个答案:

没有答案
相关问题