From 8bc80db331f13df2649c8ba2da27fa159442ec2d Mon Sep 17 00:00:00 2001 From: Laurent Bachelier Date: Wed, 9 Jan 2013 19:18:52 +0100 Subject: [PATCH] Add global "insecure" option to skip SSL validation closes #930 --- weboob/tools/application/base.py | 4 ++++ weboob/tools/browser/browser.py | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/weboob/tools/application/base.py b/weboob/tools/application/base.py index 2fee83e0..12e60a13 100644 --- a/weboob/tools/application/base.py +++ b/weboob/tools/application/base.py @@ -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: diff --git a/weboob/tools/browser/browser.py b/weboob/tools/browser/browser.py index 87a19c08..cd503f3c 100644 --- a/weboob/tools/browser/browser.py +++ b/weboob/tools/browser/browser.py @@ -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: