diff options
author | mathieui <mathieui@mathieui.net> | 2014-10-30 19:51:30 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2014-10-30 19:51:30 +0100 |
commit | 5b41fb98deee0be688d1b733023051821cabb29c (patch) | |
tree | 81115211bfdd6c0f84ebd73df4e9d5ee484aa228 | |
parent | 6da625dbdbbcb378109568ff841cb73c5324cf0d (diff) | |
download | slixmpp-5b41fb98deee0be688d1b733023051821cabb29c.tar.gz slixmpp-5b41fb98deee0be688d1b733023051821cabb29c.tar.bz2 slixmpp-5b41fb98deee0be688d1b733023051821cabb29c.tar.xz slixmpp-5b41fb98deee0be688d1b733023051821cabb29c.zip |
Add the ssl_cert and ssl_invalid_chain back
- hack the stdlib to get the peercert, remove that hack when http://bugs.python.org/issue22768 gets fixed
-rw-r--r-- | slixmpp/xmlstream/xmlstream.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py index 16e1aa22..f4f0b87e 100644 --- a/slixmpp/xmlstream/xmlstream.py +++ b/slixmpp/xmlstream/xmlstream.py @@ -453,7 +453,19 @@ class XMLStream(object): ssl_connect_routine = loop.create_connection(lambda: self, ssl=self.ssl_context, sock=self.socket, server_hostname=self.address[0]) - asyncio.async(ssl_connect_routine) + def ssl_coro(): + try: + transp, prot = yield from ssl_connect_routine + except ssl.SSLError: + import traceback + log.debug('SSL: Unable to connect:\n%s', exc_info=True) + self.event('ssl_invalid_chain', direct=True) + else: + der_cert = transp._sock.getpeercert(True) + pem_cert = ssl.DER_cert_to_PEM_cert(der_cert) + self.event('ssl_cert', pem_cert) + + asyncio.async(ssl_coro()) def _start_keepalive(self, event): """Begin sending whitespace periodically to keep the connection alive. |