Thatcher
Thatcher

Reputation: 13

Twisted server TLS hanging on connection

I have a twisted webserver with TLS authentication, and it appears to hang when I connect to it over SMTP. Here is the block of twisted code to start the server:

(Note: certificateData is our private key and public key concatenated together, that appeared to be the only way to get a self signed certificate to work)

customFactory = CustomSMTPFactory(portal)
certificate = PrivateCertificate.loadPEM(certificateData)
contextFactory = certificate.options(certificate)
tlsFactory = TLSMemoryBIOFactory(contextFactory, False, customFactory)

a = service.Application("Custom Server")
internet.TCPServer(5870, tlsFactory).setServiceParent(a)

On the client, this line just hangs waiting to read data:

smtplib.SMTP('localhost',5870)

Any ideas? How do I setup TLS authentication on a twisted webserver?

Upvotes: 1

Views: 593

Answers (1)

Glyph
Glyph

Reputation: 31860

Your server starts TLS from the beginning of the connection. Try smtplib.SMTP_SSL instead, so your client expects this.

Upvotes: 3

Related Questions