urllib3 / urllib3

urllib3 is a user-friendly HTTP client library for Python
https://urllib3.readthedocs.io
MIT License
3.79k stars 1.15k forks source link

Proxies should use proxy_ssl_context when connecting via ProxyConfig.use_forwarding_with_https = True #2577

Open sethmlarson opened 2 years ago

sethmlarson commented 2 years ago

This was discovered in https://github.com/urllib3/urllib3/pull/2558 and discussed with @jalopezsilva on Discord. The gist is it appears that we're using HTTPSConnection.ssl_context to connect to HTTPS proxies when using use_forwarding_with_https = True mode. This is likely caused by us treating the proxy like it's the origin when we have proxies in "forwarding" mode and previously we didn't have a forwarding mode for HTTPS.

Minimum requirements

:dollar: You can get paid to complete this issue! Please read the docs for more information.

fyunusa commented 2 years ago

Hi @sethmlarson have this issue been fixed ? I propose this patch for the 2.x version

if use_forwarding_for_https == True and proxy_ssl_context != None:
            if isinstance(proxy_ssl_context, ssl.SSLContext) != True:
                self.proxy_config = ProxyConfig(proxy_ssl_context, use_forwarding_for_https)

            elif proxy_ssl_context == ssl.SSLContext:
                raise ValueError(
                    "proxy ssl context should be used, not ssl context"
                )
pquentin commented 2 years ago

You will need a pull request with tests before we can review your code.

fyunusa commented 2 years ago

OK @pquentin noted I'll work on that also

sethmlarson commented 2 years ago

@umarfarouk98 this issue is already being worked on by @avi364 I think in #2651?

fyunusa commented 2 years ago

OK yeah, I see that

sg3-141-592 commented 9 months ago

Hey @abebeos , I only ever got as far as adding the ValueError exception and a unit test for it. I'm not going to be finishing this change so feel free to reuse anything that's useful off my draft PR.

alexprabhat99 commented 1 month ago

Hi @sethmlarson Is this issue fixed or still accepting PRs?