def startTLS(transport, contextFactory, normal, bypass):
 if normal:
  client = transport._tlsClientDefault
 else:
  client = (not transport._tlsClientDefault)
 (producer, streaming) = (None, None)
 if (transport.producer is not None):
  (producer, streaming) = (transport.producer, transport.streamingProducer)
  transport.unregisterProducer()
 tlsFactory = TLSMemoryBIOFactory(contextFactory, client, None)
 tlsProtocol = TLSMemoryBIOProtocol(tlsFactory, transport.protocol, False)
 transport.protocol = tlsProtocol
 transport.getHandle = tlsProtocol.getHandle
 transport.getPeerCertificate = tlsProtocol.getPeerCertificate
 directlyProvides(transport, ISSLTransport)
 transport.TLS = True
 transport.protocol.makeConnection(_BypassTLS(bypass, transport))
 if producer:
  transport.registerProducer(producer, streaming)

def startTLS ( transport , contextFactory , normal , bypass ) : if normal : client = transport . _tlsClientDefault else : client = ( not transport . _tlsClientDefault ) ( producer , streaming ) = ( None , None ) if ( transport . producer is not None ) : ( producer , streaming ) = ( transport . producer , transport . streamingProducer ) transport . unregisterProducer ( ) tlsFactory = TLSMemoryBIOFactory ( contextFactory , client , None ) tlsProtocol = TLSMemoryBIOProtocol ( tlsFactory , transport . protocol , False ) transport . protocol = tlsProtocol transport . getHandle = tlsProtocol . getHandle transport . getPeerCertificate = tlsProtocol . getPeerCertificate directlyProvides ( transport , ISSLTransport ) transport . TLS = True transport . protocol . makeConnection ( _BypassTLS ( bypass , transport ) ) if producer : transport . registerProducer ( producer , streaming )
add a layer of ssl to a transport .