Package pyxmpp :: Module streamtls :: Class StreamTLSMixIn
[hide private]

Class StreamTLSMixIn

source code

Known Subclasses:

Mix-in class providing TLS support for an XMPP stream.
Instance Methods [hide private]
 
__init__(self, tls_settings=None)
Initialize TLS support of a Stream object
source code
 
_handle_tls_features(self)
Process incoming StartTLS related element of <stream:features/>.
source code
libxml2.xmlNode
_make_stream_tls_features(self, features)
Update the <features/> with StartTLS feature.
source code
 
_make_tls_connection(self)
Initiate TLS connection.
source code
 
_process(self)
Same as Stream.process but assume self.lock is acquired.
source code
bool
_process_node_tls(self, xmlnode)
Process incoming stream element.
source code
 
_process_tls_node(self, xmlnode)
Process stream element in the TLS namespace.
source code
 
_read(self)
Read data pending on the stream socket and pass it to the parser.
source code
 
_read_tls(self)
Read data pending on the stream socket and pass it to the parser.
source code
 
_request_tls(self)
Request a TLS-encrypted connection.
source code
 
_reset_tls(self)
Reset StreamTLSMixIn object state making it ready to handle new connections.
source code
 
_write_raw(self, data)
Same as Stream.write_raw but assume self.lock is acquired.
source code
 
get_tls_connection(self)
Get the TLS connection object for the stream.
source code
 
tls_default_verify_callback(self, ok, store_context)
Default certificate verification callback for TLS connections.
source code
 
tls_is_certificate_valid(self, store_context)
Check subject name of the certificate and return True when it is valid.
source code
Instance Variables [hide private]
  tls
TLS connection object.
Method Details [hide private]

__init__(self, tls_settings=None)
(Constructor)

source code 
Initialize TLS support of a Stream object
Parameters:

_handle_tls_features(self)

source code 

Process incoming StartTLS related element of <stream:features/>.

[initiating entity only]

The received features node is available in self.features.

_make_stream_tls_features(self, features)

source code 

Update the <features/> with StartTLS feature.

[receving entity only]

Parameters:
  • features (libxml2.xmlNode) - the <features/> element of the stream.
Returns: libxml2.xmlNode
updated <features/> element node.

_make_tls_connection(self)

source code 

Initiate TLS connection.

[initiating entity only]

_process_node_tls(self, xmlnode)

source code 
Process incoming stream element. Pass it to _process_tls_node if it is in TLS namespace.
Returns: bool
True when the node was recognized as TLS element.
Raises:
  • StreamEncryptionRequired - if encryption is required by current configuration, it is not active and the element is not in the TLS namespace nor in the stream namespace.

_process_tls_node(self, xmlnode)

source code 
Process stream element in the TLS namespace.
Parameters:
  • xmlnode - the XML node received

_request_tls(self)

source code 

Request a TLS-encrypted connection.

[initiating entity only]

get_tls_connection(self)

source code 
Get the TLS connection object for the stream.
Returns:
self.tls

tls_default_verify_callback(self, ok, store_context)

source code 

Default certificate verification callback for TLS connections.

Will reject connection (return False) if M2Crypto finds any error or when certificate CommonName doesn't match peer JID.

TODO: check otherName/idOnXMPP (or what it is called)

Parameters:
  • ok - current verification result (as decided by OpenSSL).
  • store_context - certificate store context
Returns:
computed verification result.

tls_is_certificate_valid(self, store_context)

source code 

Check subject name of the certificate and return True when it is valid.

Only the certificate at depth 0 in the certificate chain (peer certificate) is checked.

Currently only the Common Name is checked and certificate is considered valid if CN is the same as the peer JID.

Parameters:
  • store_context - certificate store context, as passed to the verification callback.
Returns:
verification result. True if certificate subject name is valid.