Skip to content

Commit

Permalink
nabla-c0d3#672-fix-type-issue-while-handling-network-exception
Browse files Browse the repository at this point in the history
  • Loading branch information
msecrfe committed Nov 2, 2024
1 parent 761892b commit 73a4ff6
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions sslyze/connection_helpers/tls_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,21 @@ def connect(self, should_retry_connection: bool = True) -> None:
)
except OSError as e:
# OSError is the parent of all (non-TLS) socket/connection errors so it should be last
if "Nassl SSL handshake failed" in e.args[0]:
# Special error returned by nassl
raise ServerRejectedTlsHandshake(
server_location=self._server_location,
network_configuration=self._network_configuration,
error_message="Server interrupted the TLS handshake",
)
if isinstance(e.args[0], str):
if "Nassl SSL handshake failed" in e.args[0]:
# Special error returned by nassl
raise ServerRejectedTlsHandshake(
server_location=self._server_location,
network_configuration=self._network_configuration,
error_message="Server interrupted the TLS handshake",
)
elif isinstance(e.args[0], int):
if e.args[0] == 101:
raise ConnectionToServerFailed(
server_location=self._server_location,
network_configuration=self._network_configuration,
error_message="Network connectivity loss",
)
# Unknown connection error
raise
except _nassl.OpenSSLError as e:
Expand Down

0 comments on commit 73a4ff6

Please sign in to comment.