Package transports :: Module pyssl
[hide private]

Source Code for Module transports.pyssl

 1  # Officeshots.org - Test your office documents in different applications 
 2  # Copyright (C) 2009 Stichting Lone Wolves 
 3  # Written by Sander Marechal <s.marechal@jejik.com> 
 4  # 
 5  # This program is free software: you can redistribute it and/or modify 
 6  # it under the terms of the GNU Affero General Public License as 
 7  # published by the Free Software Foundation, either version 3 of the 
 8  # License, or (at your option) any later version. 
 9  # 
10  # This program is distributed in the hope that it will be useful, 
11  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
13  # GNU Affero General Public License for more details. 
14  # 
15  # You should have received a copy of the GNU Affero General Public License 
16  # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
17   
18  """ 
19  This module provides SSLTransport in order to have SSL client authentication 
20  with the standard xmlrpclib. It is based on Python's own httplib. 
21  """ 
22   
23  from xmlrpclib import Transport 
24   
25 -class SSLTransport(Transport):
26 """ 27 An SSL-capable transport compatible with xmlrpclib. Note that this transport 28 does not verify the server signature. Python's HTTPlib is not capable of that 29 """ 30
31 - def __init__(self, key_file, cert_file):
32 Transport.__init__(self) 33 self.key_file = key_file 34 self.cert_file = cert_file
35
36 - def make_connection(self, host):
37 """ 38 create a HTTPS connection object from a host descriptor 39 host may be a string, or a (host, x509-dict) tuple 40 """ 41 import httplib 42 host, extra_headers, x509 = self.get_host_info(host) 43 try: 44 HTTPS = httplib.HTTPS 45 except AttributeError: 46 raise NotImplementedError("your version of httplib doesn't support HTTPS") 47 else: 48 return apply(HTTPS, (host, None, self.key_file, self.cert_file), x509 or {})
49