Page 1 of 1

0.5.0Beta1 TLS support broken

Posted: December 3rd, 2009, 7:41 am
by mw
I was having problems with sabnzbd sending email after the upgrade from 0.4 to 0.5.  I did some debugging and from what I can tell, the root of the problem is that the sabnzbd.utils.ssmtplib module is not sending a STARTTLS before it tries to start an SSL session.

I'm not 100% sure what that module is for, since it seems like the smtplib module in Python already can differentiate a mail server with TLS support from one without it, in the smtplib.starttls() function.  I hacked the email.py code a bit and got it to work properly, without needing the sabnzbd.utils.ssmtplib module.  I have tested it on Postfix with and without TLS enabled and it seems to work.

It is entirely possible that I have overlooked something with that module, so please don't flame me too much if that is the case.  I am a Ruby programmer who is learning Python, so a code review from someone who knows more than I do would be a good idea. ;)

diff attached.

Re: 0.5.0Beta1 TLS support broken

Posted: December 3rd, 2009, 8:02 am
by shypike
The basics of the email module were written by someone
who was only briefly part of the team.
So in short, we're not very familiar with the module.

The comments in the SSMTP module clearly say that
a starttls should not be sent before opening the secure channel.
SMTP over SSL typical listens on port 465. Unlike StartTLS, SMTP over SSL
makes an SSL connection before doing a helo/ehlo. All transactions, then,
are done over an encrypted channel.
I'm not fully convinced that your variant works in all situations either.

Re: 0.5.0Beta1 TLS support broken

Posted: December 3rd, 2009, 10:56 am
by mw
Fair enough.  Turns out that the source of my problem was a defunct RBL in my MTA. 

You can safely disregard my post, though the SMTP over SSL standard seems to have settled on STARTTLS which is described in RFC3207, so a lot of that email.py code could be cleaned up if so desired.

Re: 0.5.0Beta1 TLS support broken

Posted: December 3rd, 2009, 12:53 pm
by shypike
You could very well be right.
It's just that the current team is not very knowledgeable in this area
and we're a bit afraid to knock over existing functionality.
By definition it's a feature that's very hard to test,
given the amount of ISPs in the world.
We settle for gmail and our own ISPs.

I'll file your suggestions in ticket anyway, lest we forget it.