8000 gh-109534: fix reference leak when SSL handshake fails by ordinary-jamie · Pull Request #114074 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-109534: fix reference leak when SSL handshake fails #114074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Revert _on_handshake_complete changes and clear exception ref
  • Loading branch information
ordinary-jamie committed Jan 15, 2024
commit e77579de6705a7bb590c179dc37d4d752878c0d4
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