diff options
author | Kim van der Riet <kpvdr@apache.org> | 2013-02-28 16:14:30 +0000 |
---|---|---|
committer | Kim van der Riet <kpvdr@apache.org> | 2013-02-28 16:14:30 +0000 |
commit | 9c73ef7a5ac10acd6a50d5d52bd721fc2faa5919 (patch) | |
tree | 2a890e1df09e5b896a9b4168a7b22648f559a1f2 /python/qpid/messaging/transports.py | |
parent | 172d9b2a16cfb817bbe632d050acba7e31401cd2 (diff) | |
download | qpid-python-asyncstore.tar.gz |
Update from trunk r1375509 through r1450773asyncstore
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/asyncstore@1451244 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid/messaging/transports.py')
-rw-r--r-- | python/qpid/messaging/transports.py | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/python/qpid/messaging/transports.py b/python/qpid/messaging/transports.py index 532c365884..e901e98258 100644 --- a/python/qpid/messaging/transports.py +++ b/python/qpid/messaging/transports.py @@ -55,7 +55,41 @@ try: from ssl import wrap_socket, SSLError, SSL_ERROR_WANT_READ, \ SSL_ERROR_WANT_WRITE except ImportError: - pass + + ## try the older python SSL api: + from socket import ssl + + class old_ssl(SocketTransport): + def __init__(self, conn, host, port): + SocketTransport.__init__(self, conn, host, port) + # Bug (QPID-4337): this is the "old" version of python SSL. + # The private key is required. If a certificate is given, but no + # keyfile, assume the key is contained in the certificate + ssl_keyfile = conn.ssl_keyfile + ssl_certfile = conn.ssl_certfile + if ssl_certfile and not ssl_keyfile: + ssl_keyfile = ssl_certfile + self.ssl = ssl(self.socket, keyfile=ssl_keyfile, certfile=ssl_certfile) + self.socket.setblocking(1) + + def reading(self, reading): + return reading + + def writing(self, writing): + return writing + + def recv(self, n): + return self.ssl.read(n) + + def send(self, s): + return self.ssl.write(s) + + def close(self): + self.socket.close() + + TRANSPORTS["ssl"] = old_ssl + TRANSPORTS["tcp+tls"] = old_ssl + else: class tls(SocketTransport): |