Package M2Crypto :: Package SSL :: Module TwistedProtocolWrapper :: Class TLSProtocolWrapper
[frames] | no frames]

Class TLSProtocolWrapper




A SSL/TLS protocol wrapper to be used with Twisted. Typically you would not use this class directly. Use connectTCP, connectSSL, listenTCP, listenSSL functions defined above, which will hook in this class.

Instance Methods
 
__init__(self, factory, wrappedProtocol, startPassThrough, client, contextFactory, postConnectionCheck)
 
clear(self)
Clear this instance, after which it is ready for reuse.
 
startTLS(self, ctx)
Start SSL/TLS.
 
write(self, data)
 
writeSequence(self, data)
 
loseConnection(self)
 
connectionMade(self)
Called when a connection is made.
 
dataReceived(self, data)
Called whenever data is received.
 
connectionLost(self, reason)
Called when the connection is shut down.

Inherited from twisted.protocols.policies.ProtocolWrapper: __getattr__, getHost, getPeer, makeConnection, registerProducer, stopConsuming, unregisterProducer

Inherited from twisted.internet.protocol.BaseProtocol: __providedBy__

Class Variables
  __implemented__ = <implementedBy M2Crypto.SSL.TwistedProtocolW...
  __provides__ = <zope.interface.declarations.ClassProvides obje...

Inherited from twisted.protocols.policies.ProtocolWrapper: disconnecting

Inherited from twisted.internet.protocol.BaseProtocol: connected, transport

Method Details

__init__(self, factory, wrappedProtocol, startPassThrough, client, contextFactory, postConnectionCheck)
(Constructor)

 
Parameters:
  • factory
  • wrappedProtocol
  • startPassThrough - If true we won't encrypt at all. Need to call startTLS() later to switch to SSL/TLS.
  • client - True if this should be a client protocol.
  • contextFactory - Factory that creates SSL.Context objects. The called function is getContext().
  • postConnectionCheck - The post connection check callback that will be called just after connection has been established but before any real data has been exchanged. The first argument to this function is an X509 object, the second is the expected host name string.
Overrides: twisted.protocols.policies.ProtocolWrapper.__init__

startTLS(self, ctx)

 

Start SSL/TLS. If this is not called, this instance just passes data through untouched.

write(self, data)

 
Overrides: twisted.protocols.policies.ProtocolWrapper.write

writeSequence(self, data)

 
Overrides: twisted.protocols.policies.ProtocolWrapper.writeSequence

loseConnection(self)

 
Overrides: twisted.protocols.policies.ProtocolWrapper.loseConnection

connectionMade(self)

 

Called when a connection is made.

This may be considered the initializer of the protocol, because it is called when the connection is completed. For clients, this is called once the connection to the server has been established; for servers, this is called after an accept() call stops blocking and a socket has been received. If you need to send any greeting or initial message, do it here.

Overrides: twisted.internet.protocol.BaseProtocol.connectionMade
(inherited documentation)

dataReceived(self, data)

 

Called whenever data is received.

Use this method to translate to a higher-level message. Usually, some callback will be made upon the receipt of each complete protocol message.

Parameters:
  • data - a string of indeterminate length. Please keep in mind that you will probably need to buffer some data, as partial (or multiple) protocol messages may be received! I recommend that unit tests for protocols call through to this method with differing chunk sizes, down to one byte at a time.
Overrides: twisted.internet.protocol.Protocol.dataReceived
(inherited documentation)

connectionLost(self, reason)

 

Called when the connection is shut down.

Clear any circular references here, and any external references to this Protocol. The connection has been closed.

Overrides: twisted.internet.protocol.Protocol.connectionLost
(inherited documentation)

Class Variable Details

__implemented__

Value:
<implementedBy M2Crypto.SSL.TwistedProtocolWrapper.TLSProtocolWrapper>

__provides__

Value:
<zope.interface.declarations.ClassProvides object at 0x8cf0e0c>