Index: urllib3-1.26.20/changelog/2577.bugfix.rst
===================================================================
--- /dev/null
+++ urllib3-1.26.20/changelog/2577.bugfix.rst
@@ -0,0 +1,2 @@
+Fixed usage of ``proxy_ssl_context`` with ``ProxyManager`` when ``use_forwarding_for_https=True``.
+Passing ``ssl_context`` instead of ``proxy_ssl_context`` for HTTPS proxies in this configuration now emits a ``FutureWarning`` and will raise an error in v3.0.
Index: urllib3-1.26.20/src/urllib3/connection.py
===================================================================
--- urllib3-1.26.20.orig/src/urllib3/connection.py
+++ urllib3-1.26.20/src/urllib3/connection.py
@@ -158,6 +158,13 @@ class HTTPConnection(_HTTPConnection, ob
         """
         self._dns_host = value
 
+    @property
+    def proxy_is_forwarding(self):
+        """
+        Return True if a forwarding proxy is configured, else return False
+        """
+        return bool(self.proxy) and self._tunnel_host is None
+
     def _new_conn(self):
         """Establish a socket connection and set nodelay settings on it.
 
@@ -392,17 +399,31 @@ class HTTPSConnection(HTTPConnection):
                 SystemTimeWarning,
             )
 
+        # Forwarding proxies should use proxy SSL context for
+        # wrapping since that's the connection being established,
+        # whereas tunneling proxies should use the connection's SSL
+        # context.
+        # However, for backwards compatibility reasons, if the proxy
+        # is forwarding but no proxy SSL context is provided, we
+        # fall back to using the connection's SSL context until
+        # urllib3 v3.0. Appropriate warning is emitted in
+        # ``ProxyManager.__init__``.
+        if self.proxy_is_forwarding and self.proxy_config is not None:
+            ssl_context = self.proxy_config.ssl_context
+        else:
+            ssl_context = self.ssl_context
+
         # Wrap socket using verification with the root certs in
         # trusted_root_certs
         default_ssl_context = False
-        if self.ssl_context is None:
+        if ssl_context is None:
             default_ssl_context = True
-            self.ssl_context = create_urllib3_context(
+            ssl_context = create_urllib3_context(
                 ssl_version=resolve_ssl_version(self.ssl_version),
                 cert_reqs=resolve_cert_reqs(self.cert_reqs),
             )
 
-        context = self.ssl_context
+        context = ssl_context
         context.verify_mode = resolve_cert_reqs(self.cert_reqs)
 
         # Try to load OS default certs if none are given.
Index: urllib3-1.26.20/src/urllib3/poolmanager.py
===================================================================
--- urllib3-1.26.20.orig/src/urllib3/poolmanager.py
+++ urllib3-1.26.20/src/urllib3/poolmanager.py
@@ -1,5 +1,7 @@
 from __future__ import absolute_import
 
+import warnings
+
 import collections
 import functools
 import logging
@@ -483,6 +485,21 @@ class ProxyManager(PoolManager):
         if proxy.scheme not in ("http", "https"):
             raise ProxySchemeUnknown(proxy.scheme)
 
+        if (
+            use_forwarding_for_https
+            and proxy.scheme == "https"
+            and connection_pool_kw.get("ssl_context") is not None
+        ):
+            warnings.warn(
+                "Passing ssl_context when use_forwarding_for_https=True is deprecated "
+                "and will raise an error in urllib3 v3.0. "
+                "Use proxy_ssl_context to configure the TLS connection to the proxy.",
+                FutureWarning,
+                stacklevel=2,
+            )
+            if proxy_ssl_context is None:
+                proxy_ssl_context = connection_pool_kw.get("ssl_context")
+
         if not proxy.port:
             port = port_by_scheme.get(proxy.scheme, 80)
             proxy = proxy._replace(port=port)
Index: urllib3-1.26.20/test/with_dummyserver/test_proxy_poolmanager.py
===================================================================
--- urllib3-1.26.20.orig/test/with_dummyserver/test_proxy_poolmanager.py
+++ urllib3-1.26.20/test/with_dummyserver/test_proxy_poolmanager.py
@@ -1,3 +1,5 @@
+import typing
+import contextlib
 import json
 import os.path
 import shutil
@@ -23,6 +25,7 @@ from dummyserver.testcase import HTTPDum
 from urllib3.util.retry import RequestHistory
 from urllib3._collections import HTTPHeaderDict
 from urllib3.connectionpool import VerifiedHTTPSConnection, connection_from_url
+from urllib3.connection import HTTPSConnection
 from urllib3.exceptions import (
     ConnectTimeoutError,
     InsecureRequestWarning,
@@ -149,6 +152,41 @@ class TestHTTPProxyManager(HTTPDummyProx
             r = https.request("GET", "%s/" % self.https_url)
             assert r.status == 200
 
+    @requires_network
+    @pytest.mark.parametrize(
+        "proxy_ssl_context_kw",
+        [
+            ("ssl_context",),
+            ("proxy_ssl_context",),
+            ("ssl_context", "proxy_ssl_context"),
+        ],
+    )
+    def test_https_proxy_forwarding_for_https_with_custom_context(self, proxy_ssl_context_kw):
+        """
+        Test that an HTTP request succeeds when using a forwarding HTTPS
+        proxy with an SSL context provided via either
+        ``proxy_ssl_context``, ``ssl_context`` (fallback), or both.
+        """
+
+        proxy_ctx = ssl.create_default_context()
+        proxy_ctx.load_verify_locations(DEFAULT_CA)
+
+        warning_checker: contextlib.AbstractContextManager[typing.Any]
+        if "ssl_context" in proxy_ssl_context_kw:
+            warning_checker = pytest.warns(Warning, match="ssl_context")
+        else:
+            warning_checker = contextlib.nullcontext()
+        with warning_checker:
+            proxy = proxy_from_url(
+                self.https_proxy_url,
+                **{kw: proxy_ctx for kw in proxy_ssl_context_kw},
+                use_forwarding_for_https=True,
+            )
+
+        with proxy:
+            resp = proxy.request("GET", self.https_url)
+            assert resp.status == 200
+
     def test_nagle_proxy(self):
         """Test that proxy connections do not have TCP_NODELAY turned on"""
         with ProxyManager(self.proxy_url) as http:
@@ -701,15 +739,8 @@ class TestHTTPProxyManager(HTTPDummyProx
             assert type(e.value.reason) == SSLError
 
     @requires_network
-    @pytest.mark.parametrize(
-        ["proxy_scheme", "use_forwarding_for_https"],
-        [
-            ("http", False),
-            ("https", False),
-            ("https", True),
-        ],
-    )
-    def test_proxy_https_target_tls_error(self, proxy_scheme, use_forwarding_for_https):
+    @pytest.mark.parametrize("proxy_scheme", ["http", "https"])
+    def test_proxy_https_target_tls_error(self, proxy_scheme):
         _should_skip_https_in_https(proxy_scheme, "https")
 
         proxy_url = self.https_proxy_url if proxy_scheme == "https" else self.proxy_url
@@ -721,12 +752,102 @@ class TestHTTPProxyManager(HTTPDummyProx
             proxy_url,
             proxy_ssl_context=proxy_ctx,
             ssl_context=ctx,
-            use_forwarding_for_https=use_forwarding_for_https,
         ) as proxy:
             with pytest.raises(MaxRetryError) as e:
                 proxy.request("GET", self.https_url)
             assert type(e.value.reason) == SSLError
 
+    @requires_network
+    def test_forwarding_proxy_tls_error_with_fallback(self) -> None:
+        """
+        Test that when only ``ssl_context`` is passed to a forwarding
+        HTTPS proxy, a ``FutureWarning`` is emitted and if the TLS
+        handshake with the proxy fails using that context, the error is
+        a ``ProxyError`` wrapping the original TLS error.
+        """
+        ctx = ssl.create_default_context()
+
+        with pytest.warns(Warning, match="ssl_context"):
+            proxy = proxy_from_url(
+                self.https_proxy_url,
+                ssl_context=ctx,
+                use_forwarding_for_https=True,
+            )
+
+        with proxy:
+            with pytest.raises(MaxRetryError) as e:
+                proxy.request("GET", self.https_url)
+            assert isinstance(e.value.reason, SSLError)
+
+    @requires_network
+    def test_forwarding_proxy_ssl_context_precedence(self) -> None:
+        """
+        Test that when both ``ssl_context`` and ``proxy_ssl_context``
+        are passed to a forwarding HTTPS proxy, ``proxy_ssl_context`` is
+        used for the proxy connection and ``ssl_context`` is ignored
+        (with a warning).
+        """
+        ssl_context = ssl.create_default_context(cafile=DEFAULT_CA)
+        proxy_ssl_context = ssl.create_default_context(cafile=DEFAULT_CA)
+
+        with pytest.warns(Warning, match="ssl_context"):
+            proxy = proxy_from_url(
+                self.https_proxy_url,
+                proxy_ssl_context=proxy_ssl_context,
+                ssl_context=ssl_context,
+                use_forwarding_for_https=True,
+            )
+
+        with proxy:
+            pool = proxy.connection_from_url(self.https_url)
+            with contextlib.closing(pool._new_conn()) as conn:
+                conn = typing.cast(HTTPSConnection, conn)
+                conn.connect()
+                assert isinstance(conn.sock, ssl.SSLSocket)
+                assert conn.sock.context is proxy_ssl_context
+
+    @requires_network
+    def test_forwarding_proxy_ssl_context_fallback(self) -> None:
+        """
+        Test that when only ``ssl_context`` is passed to a forwarding
+        HTTPS proxy, a ``FutureWarning`` is emitted and ``ssl_context``
+        is used as the proxy TLS context (fallback).
+        """
+        ssl_context = ssl.create_default_context(cafile=DEFAULT_CA)
+
+        with pytest.warns(Warning, match="ssl_context"):
+            proxy = proxy_from_url(
+                self.https_proxy_url,
+                ssl_context=ssl_context,
+                use_forwarding_for_https=True,
+            )
+
+        with proxy:
+            pool = proxy.connection_from_url(self.https_url)
+            with contextlib.closing(pool._new_conn()) as conn:
+                conn = typing.cast(HTTPSConnection, conn)
+                conn.connect()
+                assert isinstance(conn.sock, ssl.SSLSocket)
+                assert conn.sock.context is ssl_context
+
+    @requires_network
+    def test_forwarding_non_https_proxy_ssl_context_fallback(self) -> None:
+        """
+        Test that when only ``ssl_context`` is passed to a forwarding
+        non-HTTPS proxy, no warning or error is emitted.
+        """
+        ssl_context = ssl.create_default_context(cafile=DEFAULT_CA)
+        # No warning/error should be emitted even when ``ssl_context``
+        # is provided to a non-HTTPS proxy for some reason.
+        proxy = proxy_from_url(
+            self.proxy_url,
+            ssl_context=ssl_context,
+            use_forwarding_for_https=True,
+        )
+        with proxy:
+            resp = proxy.request("GET", self.https_url)
+            assert resp.status == 200
+
     def test_scheme_host_case_insensitive(self):
         """Assert that upper-case schemes and hosts are normalized."""
         with proxy_from_url(self.proxy_url.upper(), ca_certs=DEFAULT_CA) as http:
