sqlmap/lib/request/pkihandler.py

24 lines
719 B
Python
Raw Normal View History

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