summaryrefslogtreecommitdiff
path: root/qpid/python
diff options
context:
space:
mode:
authorKenneth Anthony Giusti <kgiusti@apache.org>2012-09-21 15:02:58 +0000
committerKenneth Anthony Giusti <kgiusti@apache.org>2012-09-21 15:02:58 +0000
commit1d55085f6f4fdf1a29ae7a468b189dabf9badef1 (patch)
tree340f4e2ef7eff100eb00e4be5bc6604fa16faa77 /qpid/python
parentfc62a60d120f829c2a9c3c173fb4e0db3dfba633 (diff)
downloadqpid-python-1d55085f6f4fdf1a29ae7a468b189dabf9badef1.tar.gz
QPID-4337: add SSL support for older python clients.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1388544 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/python')
-rw-r--r--qpid/python/qpid/messaging/transports.py36
-rw-r--r--qpid/python/qpid/util.py6
2 files changed, 40 insertions, 2 deletions
diff --git a/qpid/python/qpid/messaging/transports.py b/qpid/python/qpid/messaging/transports.py
index 532c365884..e901e98258 100644
--- a/qpid/python/qpid/messaging/transports.py
+++ b/qpid/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):
diff --git a/qpid/python/qpid/util.py b/qpid/python/qpid/util.py
index 39ad1d830e..5b1a876c5e 100644
--- a/qpid/python/qpid/util.py
+++ b/qpid/python/qpid/util.py
@@ -24,8 +24,12 @@ try:
except ImportError:
from socket import ssl as wrap_socket
class ssl:
-
def __init__(self, sock, keyfile=None, certfile=None, trustfile=None):
+ # 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
+ if certfile and not keyfile:
+ keyfile = certfile
self.sock = sock
self.ssl = wrap_socket(sock, keyfile=keyfile, certfile=certfile)