Skip to content

Commit

Permalink
Log clients speaking HTTP on the HTTPS port
Browse files Browse the repository at this point in the history
This patch extends the processing of a case when a client attempts
sending plain HTTP into an HTTPS port by emitting a log message.
  • Loading branch information
webknjaz committed Jan 24, 2024
1 parent eb92823 commit 93d8379
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cheroot/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,13 @@ def _from_server_socket(self, server_socket): # noqa: C901 # FIXME
f'{tls_connection_drop_error !s}',
)
return
except errors.NoSSLError:
except errors.NoSSLError as http_over_https_err:
self.server.error_log(
f'Client {addr !s} attempted to speak plain HTTP into '
'a TCP connection configured for TLS-only traffic — '
'trying to send back a plain HTTP error response: '
f'{http_over_https_err !s}',
)
msg = (
'The client sent a plain HTTP request, but '
'this server only speaks HTTPS on this port.'
Expand Down

0 comments on commit 93d8379

Please sign in to comment.