Skip to content

Commit

Permalink
Fix: Unwrap SSL socket before closing transport socket. (#737)
Browse files Browse the repository at this point in the history
* Update connections.py

Unwrap the SSL socket before closing the underlying transport socket instead of just closing SSL socket, to avoid yielding a "The TLS connection was non-properly terminated" warning in gvmd.log  on disconnect.

* cosmetics gvm/connections.py

Co-authored-by: Jaspar S. <[email protected]>
  • Loading branch information
maczal and y0urself authored May 19, 2022
1 parent 227abea commit a1fc99e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions gvm/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,15 @@ def connect(self):
self._socket = self._new_socket()
self._socket.connect((self.hostname, int(self.port)))

def disconnect(self):
"""Close the SSL layer then disconnect from the remote server"""
try:
if self._socket is not None:
self._socket = self._socket.unwrap()
except OSError as e:
logger.debug("Connection closing error: %s", e)
return super(TLSConnection, self).disconnect()


class UnixSocketConnection(GvmConnection):
"""
Expand Down

0 comments on commit a1fc99e

Please sign in to comment.