2013-02-14 11:32:17 +00:00
|
|
|
#!/usr/bin/env python
|
2010-01-02 02:07:28 +00:00
|
|
|
|
|
|
|
|
"""
|
2017-01-02 14:19:18 +01:00
|
|
|
Copyright (c) 2006-2017 sqlmap developers (http://sqlmap.org/)
|
2010-10-14 23:18:29 +00:00
|
|
|
See the file 'doc/COPYING' for copying permission
|
2010-01-02 02:07:28 +00:00
|
|
|
"""
|
|
|
|
|
|
2010-01-02 02:02:12 +00:00
|
|
|
import httplib
|
|
|
|
|
import urllib2
|
|
|
|
|
|
2010-01-07 12:59:09 +00:00
|
|
|
from lib.core.data import conf
|
|
|
|
|
|
2013-09-11 23:17:18 +02:00
|
|
|
class HTTPSPKIAuthHandler(urllib2.HTTPSHandler):
|
2015-09-27 15:59:17 +02:00
|
|
|
def __init__(self, auth_file):
|
2010-01-02 02:02:12 +00:00
|
|
|
urllib2.HTTPSHandler.__init__(self)
|
2015-09-27 15:59:17 +02:00
|
|
|
self.auth_file = auth_file
|
2010-01-02 02:07:28 +00:00
|
|
|
|
2010-01-02 02:02:12 +00:00
|
|
|
def https_open(self, req):
|
|
|
|
|
return self.do_open(self.getConnection, req)
|
2010-01-02 02:07:28 +00:00
|
|
|
|
2013-02-05 12:16:06 +01:00
|
|
|
def getConnection(self, host, timeout=None):
|
2015-09-27 15:59:17 +02:00
|
|
|
# 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)
|