diff --git a/pymongo/network_layer.py b/pymongo/network_layer.py index 4d21300bc6..c1db31f89c 100644 --- a/pymongo/network_layer.py +++ b/pymongo/network_layer.py @@ -72,7 +72,7 @@ async def async_sendall(sock: Union[socket.socket, _sslConn], buf: bytes) -> None: timeout = sock.gettimeout() sock.settimeout(0.0) - loop = asyncio.get_event_loop() + loop = asyncio.get_running_loop() try: if _HAVE_SSL and isinstance(sock, (SSLSocket, _sslConn)): await asyncio.wait_for(_async_sendall_ssl(sock, buf, loop), timeout=timeout) @@ -259,7 +259,7 @@ async def async_receive_data( timeout = sock_timeout sock.settimeout(0.0) - loop = asyncio.get_event_loop() + loop = asyncio.get_running_loop() cancellation_task = create_task(_poll_cancellation(conn)) try: if _HAVE_SSL and isinstance(sock, (SSLSocket, _sslConn)): @@ -290,7 +290,7 @@ async def async_receive_data_socket( timeout = sock_timeout sock.settimeout(0.0) - loop = asyncio.get_event_loop() + loop = asyncio.get_running_loop() try: if _HAVE_SSL and isinstance(sock, (SSLSocket, _sslConn)): return await asyncio.wait_for( diff --git a/pymongo/pyopenssl_context.py b/pymongo/pyopenssl_context.py index a320e94929..8c643394b2 100644 --- a/pymongo/pyopenssl_context.py +++ b/pymongo/pyopenssl_context.py @@ -273,7 +273,7 @@ def __set_check_ocsp_endpoint(self, value: bool) -> None: check_ocsp_endpoint = property(__get_check_ocsp_endpoint, __set_check_ocsp_endpoint) - def __get_options(self) -> None: + def __get_options(self) -> int: # Calling set_options adds the option to the existing bitmask and # returns the new bitmask. # https://www.pyopenssl.org/en/stable/api/ssl.html#OpenSSL.SSL.Context.set_options diff --git a/test/asynchronous/test_encryption.py b/test/asynchronous/test_encryption.py index ef53d8ccd5..2b22bd8b76 100644 --- a/test/asynchronous/test_encryption.py +++ b/test/asynchronous/test_encryption.py @@ -2884,6 +2884,8 @@ async def http_post(self, path, data=None): # each request because the server is single threaded. ctx = ssl.create_default_context(cafile=CA_PEM) ctx.load_cert_chain(CLIENT_PEM) + ctx.check_hostname = False + ctx.verify_mode = ssl.CERT_NONE conn = http.client.HTTPSConnection("127.0.0.1:9003", context=ctx) try: if data is not None: diff --git a/test/test_encryption.py b/test/test_encryption.py index 726463c41e..9224310144 100644 --- a/test/test_encryption.py +++ b/test/test_encryption.py @@ -2866,6 +2866,8 @@ def http_post(self, path, data=None): # each request because the server is single threaded. ctx = ssl.create_default_context(cafile=CA_PEM) ctx.load_cert_chain(CLIENT_PEM) + ctx.check_hostname = False + ctx.verify_mode = ssl.CERT_NONE conn = http.client.HTTPSConnection("127.0.0.1:9003", context=ctx) try: if data is not None: