Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop monkeypatching with pyopenssl #5477

Closed
wants to merge 1 commit into from
Closed
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
Drop monkeypatching with pyopenssl
Monkey patching url3 with pyopenssl 3 is no longer a good idea. It's
no longer really necessary, and actually has security drawbacks.

Fixes #5267

This commit reverts 50e5922.
Hugo Osvaldo Barrera committed May 29, 2020
commit 3f0356a26219170e007f54d28bfcffc42e448fb9
2 changes: 1 addition & 1 deletion AUTHORS.rst
Original file line number Diff line number Diff line change
@@ -124,7 +124,7 @@ Patches and Suggestions
- Bryce Boe <[email protected]> (`@bboe <https://github.com/bboe>`_)
- Colin Dunklau <[email protected]> (`@cdunklau <https://github.com/cdunklau>`_)
- Bob Carroll <[email protected]> (`@rcarz <https://github.com/rcarz>`_)
- Hugo Osvaldo Barrera <[email protected]> (`@hobarrera <https://github.com/hobarrera>`_)
- Hugo Osvaldo Barrera <[email protected]> (`@WhyNotHugo <https://github.com/WhyNotHugo>`_)
- Łukasz Langa <[email protected]>
- Dave Shawley <[email protected]>
- James Clarke (`@jam <https://github.com/jam>`_)
10 changes: 3 additions & 7 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -4,14 +4,10 @@ Release History
dev
---

**Improvements**

- pyOpenSSL TLS implementation is now only used if Python
either doesn't have an `ssl` module or doesn't support
SNI. Previously pyOpenSSL was unconditionally used if available.
This applies even if pyOpenSSL is installed via the
`requests[security]` extra (#5443)
**Deprecations**

- pyOpenSSL TLS is no longer patched to add extra SNI support. Python 2.7.9 or
later is now required for SNI support.

2.23.0 (2020-02-19)
-------------------
30 changes: 0 additions & 30 deletions requests/__init__.py
Original file line number Diff line number Diff line change
@@ -71,17 +71,6 @@ def check_compatibility(urllib3_version, chardet_version):
assert patch >= 2


def _check_cryptography(cryptography_version):
# cryptography < 1.3.4
try:
cryptography_version = list(map(int, cryptography_version.split('.')))
except ValueError:
return

if cryptography_version < [1, 3, 4]:
warning = 'Old version of cryptography ({}) may cause slowdown.'.format(cryptography_version)
warnings.warn(warning, RequestsDependencyWarning)

# Check imported dependencies for compatibility.
try:
check_compatibility(urllib3.__version__, chardet.__version__)
@@ -90,25 +79,6 @@ def _check_cryptography(cryptography_version):
"version!".format(urllib3.__version__, chardet.__version__),
RequestsDependencyWarning)

# Attempt to enable urllib3's fallback for SNI support
# if the standard library doesn't support SNI or the
# 'ssl' library isn't available.
try:
try:
import ssl
except ImportError:
ssl = None

if not getattr(ssl, "HAS_SNI", False):
from urllib3.contrib import pyopenssl
pyopenssl.inject_into_urllib3()

# Check cryptography version
from cryptography import __version__ as cryptography_version
_check_cryptography(cryptography_version)
except ImportError:
pass

# urllib3's DependencyWarnings should be silenced.
from urllib3.exceptions import DependencyWarning
warnings.simplefilter('ignore', DependencyWarning)
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -102,7 +102,6 @@ def run_tests(self):
cmdclass={'test': PyTest},
tests_require=test_requirements,
extras_require={
'security': ['pyOpenSSL >= 0.14', 'cryptography>=1.3.4'],
'socks': ['PySocks>=1.5.6, !=1.5.7'],
'socks:sys_platform == "win32" and python_version == "2.7"': ['win_inet_pton'],
},