summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2015-09-14 23:14:53 +0200
committermathieui <mathieui@mathieui.net>2015-09-14 23:14:53 +0200
commit82e549c0e9b6c0d5a8302c4072039512fef84e31 (patch)
tree9791de73e964bf283ebfbc6005a1c6238c64cf7f
parent1aa15792b4cddfd77c5535ab43c6d663f33a7aed (diff)
downloadslixmpp-82e549c0e9b6c0d5a8302c4072039512fef84e31.tar.gz
slixmpp-82e549c0e9b6c0d5a8302c4072039512fef84e31.tar.bz2
slixmpp-82e549c0e9b6c0d5a8302c4072039512fef84e31.tar.xz
slixmpp-82e549c0e9b6c0d5a8302c4072039512fef84e31.zip
(Temporary) fix for python 3.5
This will work until the old ssl implementation is finally deprecated. Hopefully, new features to painlessy implement starttls will be around by then.
-rw-r--r--slixmpp/__init__.py2
-rw-r--r--slixmpp/xmlstream/xmlstream.py15
2 files changed, 10 insertions, 7 deletions
diff --git a/slixmpp/__init__.py b/slixmpp/__init__.py
index 0730cc60..c09446df 100644
--- a/slixmpp/__init__.py
+++ b/slixmpp/__init__.py
@@ -6,6 +6,8 @@
See the file LICENSE for copying permission.
"""
+import asyncio
+asyncio.sslproto._is_sslproto_available=lambda: False
import logging
logging.getLogger(__name__).addHandler(logging.NullHandler())
diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py
index f6bd97a9..90afd749 100644
--- a/slixmpp/xmlstream/xmlstream.py
+++ b/slixmpp/xmlstream/xmlstream.py
@@ -287,9 +287,8 @@ class XMLStream(asyncio.BaseProtocol):
def _connect_routine(self):
self.event_when_connected = "connected"
- try:
- record = yield from self.pick_dns_answer(self.default_domain)
- except StopIteration:
+ record = yield from self.pick_dns_answer(self.default_domain)
+ if record is None:
# No more DNS records to try
self.dns_answers = None
return
@@ -497,14 +496,14 @@ class XMLStream(asyncio.BaseProtocol):
ssl_connect_routine = self.loop.create_connection(lambda: self, ssl=self.ssl_context,
sock=self.socket,
- server_hostname=self.address[0])
+ server_hostname=self.default_domain)
@asyncio.coroutine
def ssl_coro():
try:
transp, prot = yield from ssl_connect_routine
except ssl.SSLError as e:
- log.error('CERT: Invalid certificate trust chain.')
log.debug('SSL: Unable to connect', exc_info=True)
+ log.error('CERT: Invalid certificate trust chain.')
if not self.event_handled('ssl_invalid_chain'):
self.disconnect()
else:
@@ -513,7 +512,6 @@ class XMLStream(asyncio.BaseProtocol):
der_cert = transp.get_extra_info("socket").getpeercert(True)
pem_cert = ssl.DER_cert_to_PEM_cert(der_cert)
self.event('ssl_cert', pem_cert)
- self.socket = self.transport.get_extra_info("socket")
asyncio.async(ssl_coro())
@@ -663,7 +661,10 @@ class XMLStream(asyncio.BaseProtocol):
dns_records = yield from self.get_dns_records(domain, port)
self.dns_answers = iter(dns_records)
- return next(self.dns_answers)
+ try:
+ return next(self.dns_answers)
+ except StopIteration:
+ return
def add_event_handler(self, name, pointer, disposable=False):
"""Add a custom event handler that will be executed whenever