Skip to content

Commit

Permalink
Revert _on_handshake_complete changes and clear exception ref
Browse files Browse the repository at this point in the history
  • Loading branch information
ordinary-jamie committed Jan 15, 2024
1 parent 17723a5 commit e77579d
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions Lib/asyncio/sslproto.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def eof_received(self):
logger.debug("%r received EOF", self)

if self._state == SSLProtocolState.DO_HANDSHAKE:
self._on_handshake_complete(ConnectionResetError())
self._on_handshake_complete(ConnectionResetError)

elif self._state == SSLProtocolState.WRAPPED:
self._set_state(SSLProtocolState.FLUSHING)
Expand Down Expand Up @@ -571,17 +571,22 @@ def _on_handshake_complete(self, handshake_exc):
self._handshake_timeout_handle = None

sslobj = self._sslobj
if handshake_exc is None:
self._set_state(SSLProtocolState.WRAPPED)
try:
if handshake_exc is None:
self._set_state(SSLProtocolState.WRAPPED)
else:
raise handshake_exc

peercert = sslobj.getpeercert()
else:
except Exception as exc:
handshake_exc = None
self._set_state(SSLProtocolState.UNWRAPPED)
if isinstance(handshake_exc, ssl.CertificateError):
if isinstance(exc, ssl.CertificateError):
msg = 'SSL handshake failed on verifying the certificate'
else:
msg = 'SSL handshake failed'
self._fatal_error(handshake_exc, msg)
self._wakeup_waiter(handshake_exc)
self._fatal_error(exc, msg)
self._wakeup_waiter(exc)
return

if self._loop.get_debug():
Expand Down

0 comments on commit e77579d

Please sign in to comment.