jaymzh / pius

PGP Individual User Signer
Other
97 stars 25 forks source link

Unable to authenticate with SMTP server #51

Closed jwflory closed 7 years ago

jwflory commented 7 years ago

Summary

pius is unable to authenticate with an SMTP server using SSL to send signed keys to the users on a keyring.

Description

Whenever I try logging into my SMTP server to send signed keys, pius is never able to authenticate with my credentials. I last used pius around Sept. 2015 with the PrivateEmail server shown below and it worked then. However, I have tried using two different SMTP servers so I'm not sure how to proceed.

I'm not sure what more would be helpful to this issue, but I can provide more information on request.

Stacktrace

PrivateEmail

$ pius -A -r ~/.gnupg/myring.gpg -s <keyid> -m me@example.com -H mail.privateemail.com -P 465 -u me@example.com -v
Welcome to PIUS, the PGP Individual UID Signer.

NOTE: -u is present, turning off -S.
Please enter your mail server password: 
Traceback (most recent call last):
  File "/usr/bin/pius", line 341, in <module>
    main()
  File "/usr/bin/pius", line 308, in main
    if not mailer.verify_pass():
  File "/usr/lib/python2.7/site-packages/libpius/mailer.py", line 74, in verify_pass
    smtp = smtplib.SMTP(self.host, self.port)
  File "/usr/lib64/python2.7/smtplib.py", line 256, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib64/python2.7/smtplib.py", line 317, in connect
    (code, msg) = self.getreply()
  File "/usr/lib64/python2.7/smtplib.py", line 365, in getreply
    + str(e))
smtplib.SMTPServerDisconnected: Connection unexpectedly closed: [Errno 104] Connection reset by peer

SendGrid

$ pius -A -r ~/.gnupg/myring.gpg -s <keyid> -m me@example.com -H smtp.sendgrid.net -P 465 -u myusername -v
Welcome to PIUS, the PGP Individual UID Signer.

NOTE: -u is present, turning off -S.
Please enter your mail server password: 
Traceback (most recent call last):
  File "/usr/bin/pius", line 341, in <module>
    main()
  File "/usr/bin/pius", line 308, in main
    if not mailer.verify_pass():
  File "/usr/lib/python2.7/site-packages/libpius/mailer.py", line 74, in verify_pass
    smtp = smtplib.SMTP(self.host, self.port)
  File "/usr/lib64/python2.7/smtplib.py", line 256, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib64/python2.7/smtplib.py", line 317, in connect
    (code, msg) = self.getreply()
  File "/usr/lib64/python2.7/smtplib.py", line 368, in getreply
    raise SMTPServerDisconnected("Connection unexpectedly closed")
smtplib.SMTPServerDisconnected: Connection unexpectedly closed
jaymzh commented 7 years ago

As far as I can tell that port doesn't do TLS, it does native SSL instead. This is not common for SMTP, so we only support using STARTTLS to start the TLS negotiation after connection.

In fact, PrivateEmail's docs say:

Outgoing server (SMTP): 465 port for SSL, 25 or 26 for TLS/STARTTLS

So you want 25 or 26.

jwflory commented 7 years ago

@jaymzh Trying port 25 (and 26) gives me this result. ☹️

$ pius -A -r ~/.gnupg/fosdem2017.gpg -s 014131E4 -m me@example.com -H mail.privateemail.com -P 25 -u me@example.com -v
Welcome to PIUS, the PGP Individual UID Signer.

NOTE: -u is present, turning off -S.
Please enter your mail server password: 
There was a problem talking to the mail server (mail.privateemail.com): [Errno 111] Connection refused
jaymzh commented 7 years ago

Yeah, they seem to be having problems, but sendgrid looks like it works on 25.

jwflory commented 7 years ago

@jaymzh Okay, I see. I was able to successfully log into my SendGrid account on port 25. Closing issue.

jaymzh commented 7 years ago

Cool, glad I could help!