From 95276e9e3aee6b0d7dda1dde173cf8fce1b1f07e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jeremy=20Lain=C3=A9?= Date: Sat, 1 Apr 2023 16:15:31 +0200 Subject: [PATCH] [package] Use pyOpenSSL >= 23.1.0 which supports DTLS timeouts Support for DTLS timeouts was contributed upstream in PR /~https://github.com/pyca/pyopenssl/pull/1180 which was released in version 23.1.0, so we can remove our local implementation. --- setup.py | 2 +- src/aiortc/rtcdtlstransport.py | 17 ++--------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/setup.py b/setup.py index ea74fdd..d7598f6 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ "google-crc32c>=1.1", "pyee>=9.0.0", "pylibsrtp>=0.5.6", - "pyopenssl>=23.0.0", + "pyopenssl>=23.1.0", ] extras_require = { diff --git a/src/aiortc/rtcdtlstransport.py b/src/aiortc/rtcdtlstransport.py index b6d2fba..ceb4c2f 100644 --- a/src/aiortc/rtcdtlstransport.py +++ b/src/aiortc/rtcdtlstransport.py @@ -41,19 +41,6 @@ logger = logging.getLogger(__name__) -def DTLSv1_get_timeout(self): - ptv_sec = SSL._ffi.new("time_t *") - ptv_usec = SSL._ffi.new("long *") - if SSL._lib.Cryptography_DTLSv1_get_timeout(self._ssl, ptv_sec, ptv_usec): - return ptv_sec[0] + (ptv_usec[0] / 1000000) - else: - return None - - -def DTLSv1_handle_timeout(self): - SSL._lib.DTLSv1_handle_timeout(self._ssl) - - def certificate_digest(x509: crypto.X509) -> str: return x509.digest("SHA256").decode("ascii") @@ -515,7 +502,7 @@ async def _recv_next(self) -> None: # get timeout timeout = None if not self.encrypted: - timeout = DTLSv1_get_timeout(self.ssl) + timeout = self.ssl.DTLSv1_get_timeout() # receive next datagram if timeout is not None: @@ -523,7 +510,7 @@ async def _recv_next(self) -> None: data = await asyncio.wait_for(self.transport._recv(), timeout=timeout) except asyncio.TimeoutError: self.__log_debug("x DTLS handling timeout") - DTLSv1_handle_timeout(self.ssl) + self.ssl.DTLSv1_handle_timeout() await self._write_ssl() return else: