From 5637e8f02a05cf0ae800ad3e175f4bbe0a3e54cc Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 18:04:02 +0000 Subject: [PATCH] [PR #8098/aca206fc backport][3.9] Fix backwards compatibility with ssl (#8101) **This is a backport of PR #8098 as merged into 3.10 (aca206fc27ecec4e0dc14de6ab11816e7f35409c).** Fixes #8097. Co-authored-by: Sam Bull --- CHANGES/8097.bugfix.rst | 1 + CHANGES/8098.bugfix.rst | 2 ++ aiohttp/client_reqrep.py | 2 ++ tests/test_connector.py | 5 +++++ 4 files changed, 10 insertions(+) create mode 120000 CHANGES/8097.bugfix.rst create mode 100644 CHANGES/8098.bugfix.rst diff --git a/CHANGES/8097.bugfix.rst b/CHANGES/8097.bugfix.rst new file mode 120000 index 00000000000..c799b052a6c --- /dev/null +++ b/CHANGES/8097.bugfix.rst @@ -0,0 +1 @@ +8098.bugfix.rst \ No newline at end of file diff --git a/CHANGES/8098.bugfix.rst b/CHANGES/8098.bugfix.rst new file mode 100644 index 00000000000..0242fb978e5 --- /dev/null +++ b/CHANGES/8098.bugfix.rst @@ -0,0 +1,2 @@ +Fixed backwards compatibility breakage of ``ssl`` parameter when set outside of +``ClientSession`` (e.g. directly in ``TCPConnector``) -- by :user:`Dreamsorcerer`. diff --git a/aiohttp/client_reqrep.py b/aiohttp/client_reqrep.py index bb43ae9318d..e0de951a33a 100644 --- a/aiohttp/client_reqrep.py +++ b/aiohttp/client_reqrep.py @@ -159,6 +159,8 @@ def _merge_ssl_params( ssl_context: Optional["SSLContext"], fingerprint: Optional[bytes], ) -> Union["SSLContext", bool, Fingerprint]: + if ssl is None: + ssl = True # Double check for backwards compatibility if verify_ssl is not None and not verify_ssl: warnings.warn( "verify_ssl is deprecated, use ssl=False instead", diff --git a/tests/test_connector.py b/tests/test_connector.py index dc8aa3c2605..142abab3c15 100644 --- a/tests/test_connector.py +++ b/tests/test_connector.py @@ -2001,6 +2001,11 @@ async def test_default_use_dns_cache() -> None: assert conn.use_dns_cache +async def test_ssl_none() -> None: + conn = aiohttp.TCPConnector(ssl=None) + assert conn._ssl is True + + async def test_resolver_not_called_with_address_is_ip(loop) -> None: resolver = mock.MagicMock() connector = aiohttp.TCPConnector(resolver=resolver)