Add global "insecure" option to skip SSL validation

closes #930
This commit is contained in:
Laurent Bachelier 2013-01-09 19:18:52 +01:00 committed by Romain Bignon
commit 8bc80db331
2 changed files with 6 additions and 1 deletions

View file

@ -151,6 +151,7 @@ class BaseApplication(object):
logging_options.add_option('-v', '--verbose', action='store_true', help='display info messages')
logging_options.add_option('--logging-file', action='store', type='string', dest='logging_file', help='file to save logs')
logging_options.add_option('-a', '--save-responses', action='store_true', help='save every response')
logging_options.add_option('-I', '--insecure', action='store_true', help='do not validate SSL')
self._parser.add_option_group(logging_options)
self._parser.add_option('--shell-completion', action='store_true', help=optparse.SUPPRESS_HELP)
@ -304,6 +305,9 @@ class BaseApplication(object):
level = logging.ERROR
else:
level = logging.WARNING
if self.options.insecure:
from weboob.tools.browser import StandardBrowser
StandardBrowser.INSECURE = True
# this only matters to developers
if not self.options.debug and not self.options.save_responses:

View file

@ -173,6 +173,7 @@ class StandardBrowser(mechanize.Browser):
DEBUG_HTTP = False
DEBUG_MECHANIZE = False
DEFAULT_TIMEOUT = 15
INSECURE = False # if True, do not validate SSL
responses_dirname = None
responses_count = 0
@ -495,7 +496,7 @@ class BaseBrowser(StandardBrowser):
self.username = username
self.password = password
if self.CERTHASH is not None and self.DOMAIN is not None:
if not self.INSECURE and self.CERTHASH is not None and self.DOMAIN is not None:
self.lowsslcheck(self.DOMAIN, self.CERTHASH)
if self.password and get_home: