Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions news/4454.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fallback to using SecureTransport on macOS when the linked OpenSSL is too old to
support TLSv1.2.
19 changes: 19 additions & 0 deletions pip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,25 @@
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
warnings.filterwarnings("ignore", category=DependencyWarning) # noqa

# We want to inject the use of SecureTransport as early as possible so that any
# references or sessions or what have you are ensured to have it, however we
# only want to do this in the case that we're running on macOS and the linked
# OpenSSL is too old to handle TLSv1.2
try:
import ssl
except ImportError:
pass
else:
if (sys.platform == "darwin" and
ssl.OPENSSL_VERSION_NUMBER < 0x1000100f): # OpenSSL 1.0.1
try:
from pip._vendor.requests.packages.urllib3.contrib import (
securetransport,
)
except (ImportError, OSError):
pass
else:
securetransport.inject_into_urllib3()

from pip.exceptions import CommandError, PipError
from pip.utils import get_installed_distributions, get_prog
Expand Down