Where in python requests is curl --proxy-insecure analogue?

987 views Asked by At

How in python using requests package to make an https request through a proxy with disabling certificate verification (analogous to the --proxy-insecure key in curl)? My code:

import requests
requests.get('https://ip.quotaguard.com', proxies={'https': 'login:[email protected]:9294'}, verify=False)

verify=False is also used, but this is not relevant to the question, since this is an analogue of the -k switch in curl, it disables verification on ip.quotaguard.com, and on proxy eu-west-shield-01.quotaguard.com:9294 does not.

The code throws the error ValueError: check_hostname needs a SSL context with either CERT_OPTIONAL or CERT_REQUIRED.

Through curl, the request successfully returns the result, here is the request itself:

curl -x "https://login:[email protected]:9294" -L "https://ip.quotaguard.com" --proxy-insecure -k

If there is such a possibility, but not in requests, please recommend another library.

1

There are 1 answers

7
QuotaGuard On

Vladimir, I saw you're using QuotaGuard to solve this issue. I'm sorry for the delay in catching this question to get you an answer. We're just spinning up our support on SO, so again, apologize for the delay.

For your question, the first sentence in the following link is applicable: Requests is a great HTTP library for Python. It allows you to specify an authenticated proxy on a per request basis so you can pick and choose when to route through your static IP.

https://devcenter.heroku.com/articles/quotaguardshield#https-proxy-python-django

The requests library uses HTTP proxy only, not HTTPS proxy. So when listing HTTPS in the options, you are using an HTTP proxy for HTTPS requests, not an HTTPS proxy for HTTP(S) requests. Therefore, in your case, QuotaGuard Static would work, not QuotaGuard Shield. (Your connection string looks like you're on Shield)

It might help to check out the differences between QuotaGuard Static and QuotaGuard Shield, as it explains a bit why that's the case:

https://www.quotaguard.com/why-is-quotaguard-shield-more-secure-than-quotaguard-static/

I hope that helps, let me know here or reach out to us on Support if you need more assistance with the setup.