2010-01-02 05:07:28 +03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
"""
|
|
|
|
$Id$
|
|
|
|
|
2011-07-08 00:10:03 +04:00
|
|
|
Copyright (c) 2006-2011 sqlmap developers (http://www.sqlmap.org/)
|
2010-10-15 03:18:29 +04:00
|
|
|
See the file 'doc/COPYING' for copying permission
|
2010-01-02 05:07:28 +03:00
|
|
|
"""
|
|
|
|
|
2010-01-02 05:02:12 +03:00
|
|
|
import httplib
|
|
|
|
import urllib2
|
2010-03-15 17:24:43 +03:00
|
|
|
import sys
|
2010-01-02 05:02:12 +03:00
|
|
|
|
2010-01-07 15:59:09 +03:00
|
|
|
from lib.core.data import conf
|
|
|
|
|
2010-01-02 05:02:12 +03:00
|
|
|
class HTTPSCertAuthHandler(urllib2.HTTPSHandler):
|
|
|
|
def __init__(self, key_file, cert_file):
|
|
|
|
urllib2.HTTPSHandler.__init__(self)
|
|
|
|
self.key_file = key_file
|
|
|
|
self.cert_file = cert_file
|
2010-01-02 05:07:28 +03:00
|
|
|
|
2010-01-02 05:02:12 +03:00
|
|
|
def https_open(self, req):
|
|
|
|
return self.do_open(self.getConnection, req)
|
2010-01-02 05:07:28 +03:00
|
|
|
|
2010-01-02 05:02:12 +03:00
|
|
|
def getConnection(self, host):
|
2010-01-07 15:59:09 +03:00
|
|
|
if sys.version_info >= (2,6):
|
|
|
|
retVal = httplib.HTTPSConnection(host, key_file=self.key_file, cert_file=self.cert_file, timeout=conf.timeout)
|
|
|
|
else:
|
|
|
|
retVal = httplib.HTTPSConnection(host, key_file=self.key_file, cert_file=self.cert_file)
|
|
|
|
return retVal
|