Skip to content

Commit df31815

Browse files
committed
Upgrade urllib3 to 1.26.7
1 parent fabc9de commit df31815

File tree

7 files changed

+51
-7
lines changed

7 files changed

+51
-7
lines changed

news/urllib3.vendor.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Upgrade urllib3 to 1.26.7

src/pip/_vendor/urllib3/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# This file is protected via CODEOWNERS
2-
__version__ = "1.26.6"
2+
__version__ = "1.26.7"

src/pip/_vendor/urllib3/connection.py

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class BrokenPipeError(Exception):
5656
from .util.ssl_ import (
5757
assert_fingerprint,
5858
create_urllib3_context,
59+
is_ipaddress,
5960
resolve_cert_reqs,
6061
resolve_ssl_version,
6162
ssl_wrap_socket,
@@ -107,6 +108,10 @@ class HTTPConnection(_HTTPConnection, object):
107108
#: Whether this connection verifies the host's certificate.
108109
is_verified = False
109110

111+
#: Whether this proxy connection (if used) verifies the proxy host's
112+
#: certificate.
113+
proxy_is_verified = None
114+
110115
def __init__(self, *args, **kw):
111116
if not six.PY2:
112117
kw.pop("strict", None)
@@ -490,14 +495,10 @@ def _connect_tls_proxy(self, hostname, conn):
490495
self.ca_cert_dir,
491496
self.ca_cert_data,
492497
)
493-
# By default urllib3's SSLContext disables `check_hostname` and uses
494-
# a custom check. For proxies we're good with relying on the default
495-
# verification.
496-
ssl_context.check_hostname = True
497498

498499
# If no cert was provided, use only the default options for server
499500
# certificate validation
500-
return ssl_wrap_socket(
501+
socket = ssl_wrap_socket(
501502
sock=conn,
502503
ca_certs=self.ca_certs,
503504
ca_cert_dir=self.ca_cert_dir,
@@ -506,8 +507,37 @@ def _connect_tls_proxy(self, hostname, conn):
506507
ssl_context=ssl_context,
507508
)
508509

510+
if ssl_context.verify_mode != ssl.CERT_NONE and not getattr(
511+
ssl_context, "check_hostname", False
512+
):
513+
# While urllib3 attempts to always turn off hostname matching from
514+
# the TLS library, this cannot always be done. So we check whether
515+
# the TLS Library still thinks it's matching hostnames.
516+
cert = socket.getpeercert()
517+
if not cert.get("subjectAltName", ()):
518+
warnings.warn(
519+
(
520+
"Certificate for {0} has no `subjectAltName`, falling back to check for a "
521+
"`commonName` for now. This feature is being removed by major browsers and "
522+
"deprecated by RFC 2818. (See https://github.com/urllib3/urllib3/issues/497 "
523+
"for details.)".format(hostname)
524+
),
525+
SubjectAltNameWarning,
526+
)
527+
_match_hostname(cert, hostname)
528+
529+
self.proxy_is_verified = ssl_context.verify_mode == ssl.CERT_REQUIRED
530+
return socket
531+
509532

510533
def _match_hostname(cert, asserted_hostname):
534+
# Our upstream implementation of ssl.match_hostname()
535+
# only applies this normalization to IP addresses so it doesn't
536+
# match DNS SANs so we do the same thing!
537+
stripped_hostname = asserted_hostname.strip("u[]")
538+
if is_ipaddress(stripped_hostname):
539+
asserted_hostname = stripped_hostname
540+
511541
try:
512542
match_hostname(cert, asserted_hostname)
513543
except CertificateError as e:

src/pip/_vendor/urllib3/connectionpool.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,17 @@ def _validate_conn(self, conn):
10201020
InsecureRequestWarning,
10211021
)
10221022

1023+
if getattr(conn, "proxy_is_verified", None) is False:
1024+
warnings.warn(
1025+
(
1026+
"Unverified HTTPS connection done to an HTTPS proxy. "
1027+
"Adding certificate verification is strongly advised. See: "
1028+
"https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html"
1029+
"#ssl-warnings"
1030+
),
1031+
InsecureRequestWarning,
1032+
)
1033+
10231034

10241035
def connection_from_url(url, **kw):
10251036
"""

src/pip/_vendor/urllib3/contrib/_securetransport/low_level.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ def _cert_array_from_pem(pem_bundle):
188188
# We only want to do that if an error occurs: otherwise, the caller
189189
# should free.
190190
CoreFoundation.CFRelease(cert_array)
191+
raise
191192

192193
return cert_array
193194

src/pip/_vendor/urllib3/util/proxy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def create_proxy_ssl_context(
4545
ssl_version=resolve_ssl_version(ssl_version),
4646
cert_reqs=resolve_cert_reqs(cert_reqs),
4747
)
48+
4849
if (
4950
not ca_certs
5051
and not ca_cert_dir

src/pip/_vendor/vendor.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ requests==2.26.0
1313
certifi==2021.05.30
1414
chardet==4.0.0
1515
idna==3.2
16-
urllib3==1.26.6
16+
urllib3==1.26.7
1717
resolvelib==0.7.1
1818
setuptools==44.0.0
1919
six==1.16.0

0 commit comments

Comments
 (0)