Skip to content

Commit

Permalink
Merge pull request #4454 from dstufft/securetransport
Browse files Browse the repository at this point in the history
Use SecureTransport on macOS
  • Loading branch information
dstufft committed May 19, 2017
2 parents 2ae5f1e + 8467784 commit 9c03780
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
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

0 comments on commit 9c03780

Please sign in to comment.