Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SSLXMPPClient to support old style SSL connections. #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion wokkel/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""

from twisted.application import service
from twisted.internet import reactor
from twisted.internet import reactor, ssl
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to trigger a build error in TravisCI. Guess we need to install python-openssl explicitly in .travis.yml.

from twisted.names.srvconnect import SRVConnector
from twisted.words.protocols.jabber import client, sasl, xmlstream

Expand Down Expand Up @@ -142,6 +142,24 @@ def _getConnection(self):



class SSLXMPPClient(XMPPClient):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd rather just put this in XMPPClient itself, with a switch on the presence of context. Also, unit tests would be great.

"""
Service that initiates an XMPP client connection with support for old SSL conenctions.
The host must be specified for SSL to be used.
"""

def __init__(self, jid, password, host=None, port=5223, context=None):
XMPPClient.__init__(self, jid, password, host, port)
self.context = context or ssl.ClientContextFactory()

def _getConnection(self):
if self.host:
return reactor.connectSSL(self.host, self.port, self.factory, self.context)
else:
return XMPPClient._getConnection(self)



class DeferredClientFactory(generic.DeferredXmlStreamFactory):

def __init__(self, jid, password):
Expand Down