Skip to content

Commit

Permalink
Merge pull request #12944 from illia-v/urllib3-1.26.20
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr authored Sep 3, 2024
2 parents b989e6e + 8dd3988 commit a26b0ff
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion news/urllib3.vendor.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Upgrade urllib3 to 1.26.19
Upgrade urllib3 to 1.26.20
2 changes: 1 addition & 1 deletion src/pip/_vendor/urllib3/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# This file is protected via CODEOWNERS
__version__ = "1.26.19"
__version__ = "1.26.20"
3 changes: 2 additions & 1 deletion src/pip/_vendor/urllib3/connectionpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,13 @@ def _make_request(
pass
except IOError as e:
# Python 2 and macOS/Linux
# EPIPE and ESHUTDOWN are BrokenPipeError on Python 2, and EPROTOTYPE is needed on macOS
# EPIPE and ESHUTDOWN are BrokenPipeError on Python 2, and EPROTOTYPE/ECONNRESET are needed on macOS
# https://erickt.github.io/blog/2014/11/19/adventures-in-debugging-a-potential-osx-kernel-bug/
if e.errno not in {
errno.EPIPE,
errno.ESHUTDOWN,
errno.EPROTOTYPE,
errno.ECONNRESET,
}:
raise

Expand Down
17 changes: 13 additions & 4 deletions src/pip/_vendor/urllib3/util/ssl_.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from __future__ import absolute_import

import hashlib
import hmac
import os
import sys
import warnings
from binascii import hexlify, unhexlify
from hashlib import md5, sha1, sha256

from ..exceptions import (
InsecurePlatformWarning,
Expand All @@ -24,7 +24,10 @@
ALPN_PROTOCOLS = ["http/1.1"]

# Maps the length of a digest to a possible hash function producing this digest
HASHFUNC_MAP = {32: md5, 40: sha1, 64: sha256}
HASHFUNC_MAP = {
length: getattr(hashlib, algorithm, None)
for length, algorithm in ((32, "md5"), (40, "sha1"), (64, "sha256"))
}


def _const_compare_digest_backport(a, b):
Expand Down Expand Up @@ -191,9 +194,15 @@ def assert_fingerprint(cert, fingerprint):

fingerprint = fingerprint.replace(":", "").lower()
digest_length = len(fingerprint)
hashfunc = HASHFUNC_MAP.get(digest_length)
if not hashfunc:
if digest_length not in HASHFUNC_MAP:
raise SSLError("Fingerprint of invalid length: {0}".format(fingerprint))
hashfunc = HASHFUNC_MAP.get(digest_length)
if hashfunc is None:
raise SSLError(
"Hash function implementation unavailable for fingerprint length: {0}".format(
digest_length
)
)

# We need encode() here for py32; works on py2 and p33.
fingerprint_bytes = unhexlify(fingerprint.encode())
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_vendor/vendor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pyproject-hooks==1.0.0
requests==2.32.3
certifi==2024.7.4
idna==3.7
urllib3==1.26.19
urllib3==1.26.20
rich==13.7.1
pygments==2.18.0
typing_extensions==4.12.2
Expand Down

0 comments on commit a26b0ff

Please sign in to comment.