Permalink
Browse files

- use the standard 'ssl' module instead of M2Crypto

  • Loading branch information...
Jajcus committed Apr 3, 2010
1 parent 400425a commit 66100420b5abdc1866e8820d703e17ce33ebbb76
Showing with 141 additions and 150 deletions.
  1. +9 −0 CHANGES
  2. +2 −5 README
  3. +15 −4 examples/echobot.py
  4. +113 −141 pyxmpp/streamtls.py
  5. +2 −0 setup.py
@@ -5,6 +5,15 @@ Those are mentioned here as are not backward compatible.
I want the API to be stable and consistent in the next release and later,
so I do all the big changes now (I would have to do them at some time anyway).

2010-04-03

M2Crypto dependency dropped in favor of the 'ssl' module from the
standard Python library. TLS API has been changed a bit: certificate
verification callback now should expect one argument only (a dictionary
with certificate information)

Python 2.6 is now _required!

2006-08-31

Interface API for better externalisation of various components. First
7 README
@@ -39,16 +39,13 @@ Requirements

For PyXMPP you will need:

- `Python <http://www.python.org/>`__. PyXMPP was designed for Python 2.4,
and then updated for 2.5 and 2.6. If you are lucky, 2.3 will work too.
- `Python <http://www.python.org/>`__. Python 2.6 required.
- `libxml2 <http://xmlsoft.org/>`__. Recent release (>=2.6.11) with python
bindings is required. Additionally, all development files for libxml2 (usually in
separate libxml2-devel package) are recommended for compilation of PyXMPP for best performance.
PyXMPP 1.0 was tested with libxml2-2.7.2.
PyXMPP 1.0 was tested with libxml2-2.7.6.
- `dnspython <http://www.dnspython.org/>`__.
PyXMPP 1.0 was tested with version 1.6.0.
- `M2Crypto <http://wiki.osafoundation.org/bin/view/Projects/MeTooCrypto>`__
>= 0.16 for TLS support. Tested with M2Crypto-0.19.1

Installation
------------
@@ -15,6 +15,7 @@
from pyxmpp.jabber.client import JabberClient
from pyxmpp.interface import implements
from pyxmpp.interfaces import *
from pyxmpp.streamtls import TLSSettings

class EchoHandler(object):
"""Provides the actual 'echo' functionality.
@@ -172,15 +173,24 @@ class as base. That class provides basic stream setup (including
authentication) and Service Discovery server. It also does server address
and port discovery based on the JID provided."""

def __init__(self, jid, password):
def __init__(self, jid, password, tls_cacerts):
# if bare JID is provided add a resource -- it is required
if not jid.resource:
jid=JID(jid.node, jid.domain, "Echobot")

if tls_cacerts:
if tls_cacerts == 'tls_noverify':
tls_settings = TLSSettings(require = True, verify_peer = False)
else:
tls_settings = TLSSettings(require = True, cacert_file = tls_cacerts)
else:
tls_settings = None

# setup client with provided connection information
# and identity data
JabberClient.__init__(self, jid, password,
disco_name="PyXMPP example: echo bot", disco_type="bot")
disco_name="PyXMPP example: echo bot", disco_type="bot",
tls_settings = tls_settings)

# add the separate components
self.interface_providers = [
@@ -230,13 +240,14 @@ def roster_updated(self,item=None):

if len(sys.argv) < 3:
print u"Usage:"
print "\t%s JID password" % (sys.argv[0],)
print "\t%s JID password ['tls_noverify'|cacert_file]" % (sys.argv[0],)
print "example:"
print "\t%s test@localhost verysecret" % (sys.argv[0],)
sys.exit(1)

print u"creating client..."
c=Client(JID(sys.argv[1]), sys.argv[2])

c=Client(JID(sys.argv[1]), sys.argv[2], sys.argv[3] if len(sys.argv) > 3 else None)

print u"connecting..."
c.connect()
Oops, something went wrong.

0 comments on commit 6610042

Please sign in to comment.