How to use asyncore with SSL?

Marko Rauhamaa marko at pacujo.net
Fri Jan 19 00:34:45 EST 2018


Grant Edwards <grant.b.edwards at gmail.com>:

> I've been trying to use the secure smtpd module from
> https://github.com/bcoe/secure-smtpd, but the SSL support seems to be
> fundamentally broken.  That module simply wraps a socket and then
> expects to use it in the normal way via asyncore.
>
> Of course that fails the first time an ssl-wrapped-socket's send or
> recv method raises SSLWantReadError or SSLWantWriteError.  Those
> exceptions aren't handled and it crashes.
>
> That makes the SSL support pretty much useless.
>
> I'm trying to fix that, but I can't find any information or
> documentation about using asyncore with SSL.

I'm all in for asynchronous programming, but asyncore is a bit too naive
of an approach and shouldn't be used for anything serious. Python3, of
course, has the asyncio framework.

Additionally, I seem to recall Python's TLS support really supported
synchronous processing only (based on some experimentation of my own). I
hope I'm wrong on that.

> Alternatively, a pointer to a simpler smtp server library that
> supports SSL would be great. The use of asyncore and multiprocessing
> process pools by this module is _way_ overkill for my needs and
> results in something that 1) doesn't work, and 2) can't be debugged.

Haven't tried it myself, but I supposed Twisted might be what you're
looking for.

Myself, I've written several "asyncore" replacements in Python as well
as an SMTP server for my personal email needs. You could also consider
writing your own implementation. For async, there's select.epoll and the
like (assuming Linux), and SMTP is rather a simple protocol.


Marko



More information about the Python-list mailing list