Patch for an Issue #1434

This commit is contained in:
Miroslav Stampar
2015-09-27 15:59:17 +02:00
parent 38541b021a
commit 5ed106ecea
6 changed files with 15 additions and 13 deletions

View File

@@ -11,12 +11,13 @@ import urllib2
from lib.core.data import conf
class HTTPSPKIAuthHandler(urllib2.HTTPSHandler):
def __init__(self, key_file):
def __init__(self, auth_file):
urllib2.HTTPSHandler.__init__(self)
self.key_file = key_file
self.auth_file = auth_file
def https_open(self, req):
return self.do_open(self.getConnection, req)
def getConnection(self, host, timeout=None):
return httplib.HTTPSConnection(host, key_file=self.key_file, timeout=conf.timeout)
# Reference: https://docs.python.org/2/library/ssl.html#ssl.SSLContext.load_cert_chain
return httplib.HTTPSConnection(host, cert_file=self.auth_file, key_file=self.auth_file, timeout=conf.timeout)