【发布时间】:2020-09-01 22:56:43
【问题描述】:
我正在尝试通过 HTTPS 隧道发送 HTTPS 请求。也就是说,我的代理需要 HTTPS 进行 CONNECT。它还需要客户端证书。
我正在使用Requests' proxy features。
import requests
url = "https://some.external.com/endpoint"
with requests.Session() as session:
response = session.get(
url,
proxies={"https": "https://proxy.host:4443"},
# client certificates expected by proxy
cert=(cert_path, key_path),
verify="/home/savior/proxy-ca-bundle.pem",
)
with response:
...
这可行,但有一些限制:
- 我只能为与代理的 TLS 连接设置客户端证书,而不能为外部端点设置客户端证书。
-
proxy-ca-bundle.pem仅验证与代理的 TLS 连接中的服务器证书。来自外部端点的服务器证书似乎被忽略了。
有没有办法使用requests 来解决这两个问题?我想为外部端点设置一组不同的 CA。
我也尝试过使用http.client 和HTTPSConnection.set_tunnel,但据我所知,它的隧道是通过 HTTP 完成的,我需要 HTTPS。
【问题讨论】:
标签: python ssl https python-requests http-tunneling