diff options
| author | Rafael H. Schloming <rhs@apache.org> | 2008-10-28 23:15:27 +0000 |
|---|---|---|
| committer | Rafael H. Schloming <rhs@apache.org> | 2008-10-28 23:15:27 +0000 |
| commit | 86ed9f4cc99564e80ba3cdd891a5608f4f35c55f (patch) | |
| tree | 9400ad35c20b6b5821274491816e6844cdd8eed0 /python/qpid/connection.py | |
| parent | f2020671d5bcc87b956c3890ff7131742232dc4b (diff) | |
| download | qpid-python-86ed9f4cc99564e80ba3cdd891a5608f4f35c55f.tar.gz | |
ssl support for the python client
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@708718 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid/connection.py')
| -rw-r--r-- | python/qpid/connection.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/python/qpid/connection.py b/python/qpid/connection.py index ce27a74489..4c9c02822a 100644 --- a/python/qpid/connection.py +++ b/python/qpid/connection.py @@ -17,7 +17,7 @@ # under the License. # -import datatypes, session +import datatypes, session, socket from threading import Thread, Condition, RLock from util import wait, notify from assembler import Assembler, Segment @@ -44,10 +44,27 @@ def client(*args, **kwargs): def server(*args, **kwargs): return delegates.Server(*args, **kwargs) +class SSLWrapper: + + def __init__(self, ssl): + self.ssl = ssl + + def recv(self, n): + return self.ssl.read(n) + + def send(self, s): + return self.ssl.write(s) + +def sslwrap(sock): + if isinstance(sock, socket.SSLType): + return SSLWrapper(sock) + else: + return sock + class Connection(Assembler): def __init__(self, sock, spec=None, delegate=client, **args): - Assembler.__init__(self, sock) + Assembler.__init__(self, sslwrap(sock)) if spec == None: spec = load(default()) self.spec = spec |
