diff options
author | Mathias Ertl <mati@er.tl> | 2017-05-05 16:47:25 +0200 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2017-05-24 11:31:13 +0200 |
commit | aaa45846d3dd3bd826284200a693e0cbf3efca0d (patch) | |
tree | d9fa53a931dee001afacdeee174ecfc92b80ec52 | |
parent | d7ffcb54eb324132e12ca92ac80cb664ce88558a (diff) | |
download | slixmpp-aaa45846d3dd3bd826284200a693e0cbf3efca0d.tar.gz slixmpp-aaa45846d3dd3bd826284200a693e0cbf3efca0d.tar.bz2 slixmpp-aaa45846d3dd3bd826284200a693e0cbf3efca0d.tar.xz slixmpp-aaa45846d3dd3bd826284200a693e0cbf3efca0d.zip |
add function to explicitly get the ssl context
-rw-r--r-- | slixmpp/xmlstream/xmlstream.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py index 704a34f1..4ff9fc58 100644 --- a/slixmpp/xmlstream/xmlstream.py +++ b/slixmpp/xmlstream/xmlstream.py @@ -488,14 +488,10 @@ class XMLStream(asyncio.BaseProtocol): """ pass - def start_tls(self): - """Perform handshakes for TLS. - - If the handshake is successful, the XML stream will need - to be restarted. + def get_ssl_context(self): + """ + Get SSL context. """ - self.event_when_connected = "tls_success" - if self.ciphers is not None: self.ssl_context.set_ciphers(self.ciphers) if self.keyfile and self.certfile: @@ -510,7 +506,18 @@ class XMLStream(asyncio.BaseProtocol): self.ssl_context.verify_mode = ssl.CERT_REQUIRED self.ssl_context.load_verify_locations(cafile=self.ca_certs) - ssl_connect_routine = self.loop.create_connection(lambda: self, ssl=self.ssl_context, + return self.ssl_context + + def start_tls(self): + """Perform handshakes for TLS. + + If the handshake is successful, the XML stream will need + to be restarted. + """ + self.event_when_connected = "tls_success" + + ssl_context = self.get_ssl_context() + ssl_connect_routine = self.loop.create_connection(lambda: self, ssl=ssl_context, sock=self.socket, server_hostname=self.default_domain) @asyncio.coroutine |