Twisted SMTP server, adding SSL support, 2 factories? -
Recently it has been said that I was barking the wrong tree - so now it's fresh, modified question .
So I am trying to expand the original SMTP server sample found to support SSL connections. I can create an SSL Pract Factory: (Code taken from my previous attempts:
caCertFile = open ("/ opt / tesa / etc / certs / ca / cacert.pem" , "R") CertFile = open ("/ opt / tesa / etc / certs / server / server.crt", "r") keyFile = open ("/ opt / tesa / etc / certs / server / server.key" , "r") CaCertData = caCertFile.read () pKeyData = keyFile.read () certData = certFile.read () caCert = ssl.Certificate.loadPEM (caCertData) certificate = load_certificate (FILETYPE_PEM, certData) pKey = load_privatekey (FILETYPE_PEM, pKeyData) sslCtxFactory = ssl.CertificateOptions (privateKey = pKey, certificate = certificate, trustRoot = caCert)
now I SMTP Factory emailserver.tac, and above my Minister of sslCtxFactory. In my old code, I class created as follows an object of ESMTP:
myESMTP = ESMTP (contextFactory = sslCtxFactory) factory = protocol.Factory.forProtocol (lambda: MySMTP (contextFactory = sslCtxFactory) endpoint = endpoints.TCP4ServerEndpoint (reactor, 8001) endpoint List (factory)
But since this code is not using any portals etc., some methods / functions are not defined in Class Definition for ASMTPP different properties The reasons fail (such as self-delivery, self.)
So I'm trying to understand how to implement my sslCtxFactory in the mailserver.tac code - while still per mailserver.tac By using a portal / realm in the form,
Thanks
it looks odd:
myESMTP = ESMTP (contextFactory = sslCtxFactory) factory = protocol.Factory.forProtocol (lambda: mySMTP (contextFactory = sslCtxFactory))
Examples of the ESMTP
class provided by twists are not eligible to call. I think you must like something means:
import functools partial myESMTP = partial (ESMTP, contextFactory = sslCtxFactory) factory = protocol.Factory.forProtocol (mySMTP)
Assuming that ...
ESMTP
class honor the self.portal
attribute for its authentication and authorization behavior. Does. instead of SMTP
Code> ESMTP creates an example.
Fortunately, this (factory) respects its protocol
to instantify the feature.
If you want to type:
portal = portal (...) myESMTP = partial (ESMTP, contextFactory = ...) Factory = SMTPFactory.forProtocol (protocol) portal << li> sets portal context < Examples of / code>> ESMTP
are expected by using the value passed in for here On.
Comments
Post a Comment