Skip to content

Instantly share code, notes, and snippets.

@mocmocamoc
Created December 12, 2017 17:58
Show Gist options
  • Save mocmocamoc/8544c288a486e95514fc982a7a0e8620 to your computer and use it in GitHub Desktop.
Save mocmocamoc/8544c288a486e95514fc982a7a0e8620 to your computer and use it in GitHub Desktop.
asyncio SSL handshake timeout patch
import asyncio
def checkHandshakeDone(self):
if self._in_handshake == True:
self._abort()
asyncio.sslproto.SSLProtocol.checkHandshakeDone = checkHandshakeDone
_start_handshake_orig = asyncio.sslproto.SSLProtocol._start_handshake
def _start_handshake(self):
_start_handshake_orig(self)
self._loop.call_later(10, self.checkHandshakeDone)
asyncio.sslproto.SSLProtocol._start_handshake = _start_handshake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment