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

Emit warning when there's no ssl.OP_NO_COMPRESSION #4052

Merged
merged 2 commits into from
Sep 9, 2019
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
3 changes: 3 additions & 0 deletions CHANGES/4052.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Emit a warning when :py:attr:`ssl.OP_NO_COMPRESSION` is
unavailable because the runtime is built against
an outdated OpenSSL.
11 changes: 10 additions & 1 deletion aiohttp/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,16 @@ def _make_ssl_context(verified: bool) -> SSLContext:
sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
sslcontext.options |= ssl.OP_NO_SSLv2
sslcontext.options |= ssl.OP_NO_SSLv3
sslcontext.options |= ssl.OP_NO_COMPRESSION
try:
sslcontext.options |= ssl.OP_NO_COMPRESSION
except AttributeError as attr_err:
warnings.warn(
'{!s}: The Python interpreter is compiled '
'against OpenSSL < 1.0.0. Ref: '
'https://docs.python.org/3/library/ssl.html'
'#ssl.OP_NO_COMPRESSION'.
format(attr_err),
)
sslcontext.set_default_verify_paths()
return sslcontext

Expand Down
4 changes: 3 additions & 1 deletion pytest.ci.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[pytest]
addopts = --cov=aiohttp --cov-report term-missing:skip-covered --cov-report xml --junitxml=.test-results/pytest/results.xml -v -rxXs --durations 10
filterwarnings = error
filterwarnings =
error
ignore:module 'ssl' has no attribute 'OP_NO_COMPRESSION'. The Python interpreter is compiled against OpenSSL < 1.0.0. Ref. https.//docs.python.org/3/library/ssl.html#ssl.OP_NO_COMPRESSION:UserWarning
junit_suite_name = aiohttp_test_suite
norecursedirs = dist docs build .tox .eggs
minversion = 3.8.2
Expand Down
4 changes: 3 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[pytest]
addopts = --cov=aiohttp -v -rxXs
filterwarnings = error
filterwarnings =
error
ignore:module 'ssl' has no attribute 'OP_NO_COMPRESSION'. The Python interpreter is compiled against OpenSSL < 1.0.0. Ref. https.//docs.python.org/3/library/ssl.html#ssl.OP_NO_COMPRESSION:UserWarning
junit_suite_name = aiohttp_test_suite
norecursedirs = dist docs build .tox .eggs
minversion = 3.8.2
Expand Down