1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 """
17 Contains custom QPID transport classes.
18 """
19
20 import ssl
21 from gofer.messaging.broker import Broker
22 from qpid.messaging.transports import connect, TRANSPORTS, tls
23 from logging import getLogger
24
25 log = getLogger(__name__)
26
27
29 """
30 SSL Transport.
31 Extends L{tls} to support client certificates.
32 """
33
35 """
36 @param args: The argument list.
37 Using arglist for compatability with many versions
38 For <= 0.8 passed (host, port)
39 For 0.10 (el6) passed (con, host, port)
40 @type args: list
41 """
42 host, port = args[-2:]
43 url = ':'.join((host,str(port)))
44 broker = Broker(url)
45 if broker.cacert:
46 reqcert = ssl.CERT_REQUIRED
47 else:
48 reqcert = ssl.CERT_NONE
49 self.socket = connect(host, port)
50 self.tls = \
51 ssl.wrap_socket(
52 self.socket,
53 cert_reqs=reqcert,
54 ca_certs=broker.cacert,
55 certfile=broker.clientcert)
56 self.socket.setblocking(0)
57 self.state = None
58
59
60
61
62 TRANSPORTS['ssl'] = SSL
63