scanner / as_email_service

A Django app and smtp relay service for working with 3rd party email services and asimap
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Do not generate stack traces on SSL connection resets #95

Closed scanner closed 11 months ago

scanner commented 11 months ago

If we get a connection reset while negotiating SSL it currently generates a stack trace. We do not need this. It failed. Log an error and moved on. The stack trace does little good except adding lines to the log making it harder to read.

smtpd   | [2023-11-11 18:11:23,574] ERROR:aiosmtpd.handle_exception: ('1.2.3.4', 50601) SMTP session exception
smtpd   | Traceback (most recent call last):
smtpd   |   File "/venv/lib/python3.11/site-packages/aiosmtpd/smtp.py", line 914, in smtp_STARTTLS
smtpd   |     await waiter
smtpd   |   File "/usr/local/lib/python3.11/asyncio/sslproto.py", line 575, in _on_handshake_complete
smtpd   |     raise handshake_exc
smtpd   | ConnectionResetError
smtpd   | 
smtpd   | The above exception was the direct cause of the following exception:
smtpd   | 
smtpd   | Traceback (most recent call last):
smtpd   |   File "/venv/lib/python3.11/site-packages/aiosmtpd/smtp.py", line 741, in _handle_client
smtpd   |     await method(arg)
smtpd   |   File "/venv/lib/python3.11/site-packages/aiosmtpd/smtp.py", line 918, in smtp_STARTTLS
smtpd   |     raise TLSSetupException() from error
smtpd   | aiosmtpd.smtp.TLSSetupException