t.p.tls : module documentation

Part of twisted.protocols View Source

Implementation of a TLS transport (ISSLTransport) as an IProtocol layered on top of any ITransport implementation, based on OpenSSL's memory BIO features.

TLSMemoryBIOFactory is a WrappingFactory which wraps protocols created by the factory it wraps with TLSMemoryBIOProtocol. TLSMemoryBIOProtocol intercedes between the underlying transport and the wrapped protocol to implement SSL and TLS. Typical usage of this module looks like this:

   from twisted.protocols.tls import TLSMemoryBIOFactory
   from twisted.internet.protocol import ServerFactory
   from twisted.internet.ssl import PrivateCertificate
   from twisted.internet import reactor

   from someapplication import ApplicationProtocol

   serverFactory = ServerFactory()
   serverFactory.protocol = ApplicationProtocol
   certificate = PrivateCertificate.loadPEM(certPEMData)
   contextFactory = certificate.options()
   tlsFactory = TLSMemoryBIOFactory(contextFactory, False, serverFactory)
   reactor.listenTCP(12345, tlsFactory)
   reactor.run()

This API offers somewhat more flexibility than twisted.internet.interfaces.IReactorSSL; for example, a TLSMemoryBIOProtocol instance can use another instance of TLSMemoryBIOProtocol as its transport, yielding TLS over TLS - useful to implement onion routing. It can also be used to run TLS over unusual transports, such as UNIX sockets and stdio.

Class TLSMemoryBIOProtocol No summary
Class TLSMemoryBIOFactory TLSMemoryBIOFactory adds TLS to connections.
Class _PullToPush An adapter that converts a non-streaming to a streaming producer.
Class _ProducerMembrane Stand-in for producer registered with a TLSMemoryBIOProtocol transport.
API Documentation for Twisted, generated by pydoctor at 2012-09-01 11:44:56.