Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSL is slow #388

Open
azmeuk opened this issue Apr 19, 2024 · 0 comments
Open

SSL is slow #388

azmeuk opened this issue Apr 19, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@azmeuk
Copy link
Contributor

azmeuk commented Apr 19, 2024

Sending a single mail to smtpdfix with SSL enabled on a very capable computer can take more than 1s.

This can easily be reproduced with this test:

import email.message
import smtplib


def test_send_email_ssl(smtpd):
    smtpd.config.use_ssl = True
    smtpd.config.use_starttls = False

    msg = email.message.EmailMessage()
    msg["To"] = "<foobar@example.org>"

    with smtplib.SMTP_SSL(smtpd.hostname, smtpd.port) as smtp:
        smtp.send_message(msg)

    assert smtpd.messages
$ time pytest --disable-warnings --durations 1 test_ssl.py
=============================================== test session starts ================================================
platform linux -- Python 3.12.2, pytest-8.1.1, pluggy-1.4.0
rootdir: /home/eloi/test
plugins: smtpdfix-0.5.1
collected 1 item

test_ssl.py .                                                                                                [100%]

=============================================== slowest 1 durations ================================================
2.04s call     test_ssl.py::test_send_test_email_ssl
========================================== 1 passed, 2 warnings in 2.09s ===========================================
pytest --disable-warnings --durations 1 test_ssl.py  0,40s user 0,04s system 17% cpu 2,442 total

Here the test takes 2,04s, but without SSL it would take 0.01s.
Duplicating the very same ssl test takes twice as long, so whatever is causing this delay is executed on each test.

I suspect being slow is something hard to avoid with SSL, but maybe there are strategies to mitigate this? Whatever takes time, are there things to cache during the test sessions, less secure algorithms to choose, or shorter keys, so everything goes fast?

Any thoughts?

Environment

  • OS: Archlinux
  • Python version 3.12
@azmeuk azmeuk added the bug Something isn't working label Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant