Permalink
Browse files

Fixed the HTTPTLSConnection in xmlrpctransport and added support

for ignoreAbruptClose in xmlrpc transport and httptls connection
  • Loading branch information...
keesbos committed Mar 13, 2012
1 parent 0b8a1e9 commit eb4b7c9e64505bd3917d6b677813e0973b2bcbe6
Showing with 22 additions and 10 deletions.
  1. +9 −3 tlslite/integration/httptlsconnection.py
  2. +13 −7 tlslite/integration/xmlrpctransport.py
@@ -20,7 +20,8 @@ def __init__(self, host, port=None, strict=None,
x509Fingerprint=None,
tackID=None,
hardTack=None,
- settings = None):
+ settings=None,
+ ignoreAbruptClose=False):
"""Create a new HTTPTLSConnection.
For client authentication, use one of these argument
@@ -83,14 +84,18 @@ def __init__(self, host, port=None, strict=None,
@param settings: Various settings which can be used to control
the ciphersuites, certificate types, and SSL/TLS versions
offered by the client.
+
+ @type ignoreAbruptClose: bool
+ @param ignoreAbruptClose: ignore the TLSAbruptCloseError on
+ unexpected hangup.
"""
if source_address:
httplib.HTTPConnection.__init__(self, host, port, strict,
timeout, source_address)
if not source_address:
httplib.HTTPConnection.__init__(self, host, port, strict,
timeout)
-
+ self.ignoreAbruptClose = ignoreAbruptClose
ClientHelper.__init__(self,
username, password,
certChain, privateKey,
@@ -102,4 +107,5 @@ def __init__(self, host, port=None, strict=None,
def connect(self):
httplib.HTTPConnection.connect(self)
self.sock = TLSConnection(self.sock)
- ClientHelper._handshake(self, self.sock)
+ self.sock.ignoreAbruptClose = self.ignoreAbruptClose
+ ClientHelper._handshake(self, self.sock)
@@ -7,6 +7,7 @@
import httplib
from tlslite.integration.httptlsconnection import HTTPTLSConnection
from tlslite.integration.clienthelper import ClientHelper
+import tlslite.errors
class XMLRPCTransport(xmlrpclib.Transport, ClientHelper):
@@ -23,7 +24,8 @@ def __init__(self, use_datetime=0,
x509Fingerprint=None,
tackID=None,
hardTack=None,
- settings=None):
+ settings=None,
+ ignoreAbruptClose=False):
"""Create a new XMLRPCTransport.
An instance of this class can be passed to L{xmlrpclib.ServerProxy}
@@ -88,12 +90,15 @@ def __init__(self, use_datetime=0,
@param settings: Various settings which can be used to control
the ciphersuites, certificate types, and SSL/TLS versions
offered by the client.
+
+ ignoreAbruptClose
"""
# self._connection is new in pythion 2.7, since we're using it here,
# we'll add this ourselves too, just in case we've pre-2.7
self._connection = (None, None)
xmlrpclib.Transport.__init__(self, use_datetime)
+ self.ignoreAbruptClose = ignoreAbruptClose
ClientHelper.__init__(self,
username, password,
certChain, privateKey,
@@ -112,12 +117,13 @@ def make_connection(self, host):
chost, extra_headers, x509 = self.get_host_info(host)
http = HTTPTLSConnection(chost, None,
- self.username, self.password,
- self.certChain, self.privateKey,
- self.checker.x509Fingerprint,
- self.checker.tackID,
- self.checker.hardTack,
- self.settings)
+ username=self.username, password=self.password,
+ certChain=self.certChain, privateKey=self.privateKey,
+ x509Fingerprint=self.checker.x509Fingerprint,
+ tackID=self.checker.tackID,
+ hardTack=self.checker.hardTack,
+ settings=self.settings,
+ ignoreAbruptClose=self.ignoreAbruptClose)
# store the host argument along with the connection object
self._connection = host, http
if not self.conn_class_is_http:

0 comments on commit eb4b7c9

Please sign in to comment.