Warn that SSLSocket cannot send close_notify TLS alerts (#621)

* Warn that SSLSocket cannot send close_notify TLS alerts.

* Improve formulation.

Co-authored-by: Don Naro <dnaro@redhat.com>

---------

Co-authored-by: Don Naro <dnaro@redhat.com>
This commit is contained in:
Felix Fontein
2023-05-15 21:41:23 +02:00
committed by GitHub
parent 6187068ee5
commit 245ab76b09
5 changed files with 19 additions and 0 deletions
+4
View File
@@ -36,6 +36,10 @@ def _empty_writer(msg):
def shutdown_writing(sock, log=_empty_writer):
# FIXME: This does **not work with SSLSocket**! Apparently SSLSocket does not allow to send
# a close_notify TLS alert without completely shutting down the connection.
# Calling sock.shutdown(pysocket.SHUT_WR) simply turns of TLS encryption and from that
# point on the raw encrypted data is returned when sock.recv() is called. :-(
if hasattr(sock, 'shutdown_write'):
sock.shutdown_write()
elif hasattr(sock, 'shutdown'):