add function to explicitly get the ssl context

This commit is contained in:
Mathias Ertl 2017-05-05 16:47:25 +02:00 committed by louiz’
parent d7ffcb54eb
commit aaa45846d3

View File

@ -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