diff options
Diffstat (limited to 'sleekxmpp/xmlstream')
-rw-r--r-- | sleekxmpp/xmlstream/scheduler.py | 2 | ||||
-rw-r--r-- | sleekxmpp/xmlstream/xmlstream.py | 31 |
2 files changed, 22 insertions, 11 deletions
diff --git a/sleekxmpp/xmlstream/scheduler.py b/sleekxmpp/xmlstream/scheduler.py index 945d9fad..40aaf695 100644 --- a/sleekxmpp/xmlstream/scheduler.py +++ b/sleekxmpp/xmlstream/scheduler.py @@ -76,7 +76,7 @@ class Scheduler(object): if updated: self.schedule = sorted(self.schedule, key=lambda task: task.next) except KeyboardInterrupt: self.run = False - logging.debug("Qutting Scheduler thread") + logging.debug("Quitting Scheduler thread") if self.parentqueue is not None: self.parentqueue.put(('quit', None, None)) diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py index cea300a7..217367f9 100644 --- a/sleekxmpp/xmlstream/xmlstream.py +++ b/sleekxmpp/xmlstream/xmlstream.py @@ -70,6 +70,7 @@ class XMLStream(object): self.filesocket = None self.use_ssl = False self.use_tls = False + self.ca_certs=None self.stream_header = "<stream>" self.stream_footer = "</stream>" @@ -114,7 +115,7 @@ class XMLStream(object): self.socket.settimeout(None) if self.use_ssl and self.ssl_support: logging.debug("Socket Wrapped for SSL") - self.socket = ssl.wrap_socket(self.socket) + self.socket = ssl.wrap_socket(self.socket,ca_certs=self.ca_certs) try: self.socket.connect(self.address) #self.filesocket = self.socket.makefile('rb', 0) @@ -133,8 +134,13 @@ class XMLStream(object): if self.ssl_support: logging.info("Negotiating TLS") self.realsocket = self.socket - self.socket = ssl.wrap_socket(self.socket, ssl_version=ssl.PROTOCOL_TLSv1, do_handshake_on_connect=False) + self.socket = ssl.wrap_socket(self.socket, + ssl_version=ssl.PROTOCOL_TLSv1, + do_handshake_on_connect=False, + ca_certs=self.ca_certs) + print "doing handshake..." self.socket.do_handshake() + print "got handshake..." if sys.version_info < (3,0): from . filesocket import filesocket self.filesocket = filesocket(self.socket) @@ -149,14 +155,19 @@ class XMLStream(object): def process(self, threaded=True): self.scheduler.process(threaded=True) for t in range(0, HANDLER_THREADS): - logging.debug("Starting HANDLER THREAD") - self.__thread['eventhandle%s' % t] = threading.Thread(name='eventhandle%s' % t, target=self._eventRunner) - self.__thread['eventhandle%s' % t].start() - self.__thread['sendthread'] = threading.Thread(name='sendthread', target=self._sendThread) - self.__thread['sendthread'].start() + th = threading.Thread(name='eventhandle%s' % t, target=self._eventRunner) + th.setDaemon(True) + self.__thread['eventhandle%s' % t] = th + th.start() + th = threading.Thread(name='sendthread', target=self._sendThread) + th.setDaemon(True) + self.__thread['sendthread'] = th + th.start() if threaded: - self.__thread['process'] = threading.Thread(name='process', target=self._process) - self.__thread['process'].start() + th = threading.Thread(name='process', target=self._process) + th.setDaemon(True) + self.__thread['process'] = th + th.start() else: self._process() @@ -297,7 +308,7 @@ class XMLStream(object): self.state.set('tls',False) self.state.set('ssl',False) time.sleep(1) - self.connect() + self.connect(self.server,self.port) def incoming_filter(self, xmlobj): return xmlobj |