Commit e12485dc authored by Florent Fourcot's avatar Florent Fourcot

Introduce local exception for SSL errors

It removes the import of SSL in console applications (SSL -> socket ->
base64 -> ...)
parent b8453fb0
......@@ -27,14 +27,13 @@ import subprocess
import sys
import os
import locale
from ssl import SSLError
from weboob.capabilities import UserError
from weboob.capabilities.account import CapAccount, Account, AccountRegisterError
from weboob.core.backendscfg import BackendAlreadyExists
from weboob.core.modules import ModuleLoadError
from weboob.core.repositories import ModuleInstallError
from weboob.tools.exceptions import BrowserUnavailable, BrowserIncorrectPassword, BrowserForbidden
from weboob.tools.exceptions import BrowserUnavailable, BrowserIncorrectPassword, BrowserForbidden, BrowserSSLError
from weboob.tools.value import Value, ValueBool, ValueFloat, ValueInt, ValueBackendPassword
from weboob.tools.misc import to_unicode
from weboob.tools.ordereddict import OrderedDict
......@@ -545,7 +544,7 @@ class ConsoleApplication(BaseApplication):
print(u'Error(%s): %s' % (backend.name, to_unicode(error)), file=sys.stderr)
elif isinstance(error, MoreResultsAvailable):
print(u'Hint: There are more results for backend %s' % (backend.name), file=sys.stderr)
elif isinstance(error, SSLError):
elif isinstance(error, BrowserSSLError):
print(u'FATAL(%s): ' % backend.name + self.BOLD + '/!\ SERVER CERTIFICATE IS INVALID /!\\' + self.NC, file=sys.stderr)
else:
print(u'Bug(%s): %s' % (backend.name, to_unicode(error)), file=sys.stderr)
......
......@@ -49,7 +49,7 @@ from contextlib import closing
from gzip import GzipFile
import warnings
from weboob.tools.exceptions import BrowserUnavailable, BrowserIncorrectPassword, BrowserPasswordExpired, BrowserForbidden, BrowserBanned, BrowserHTTPNotFound, BrowserHTTPError, FormFieldConversionWarning
from weboob.tools.exceptions import BrowserUnavailable, BrowserIncorrectPassword, BrowserPasswordExpired, BrowserForbidden, BrowserBanned, BrowserHTTPNotFound, BrowserHTTPError, FormFieldConversionWarning, BrowserSSLError
from weboob.tools.decorators import retry
from weboob.tools.log import getLogger
from weboob.tools.mech import ClientForm
......@@ -409,7 +409,7 @@ class StandardBrowser(mechanize.Browser):
if isinstance(hsh, basestring):
hsh = [hsh]
if certhash not in hsh:
raise ssl.SSLError()
raise BrowserSSLError()
def _certhash(self, domain, port=443):
certs = ssl.get_server_certificate((domain, port))
......
......@@ -46,6 +46,10 @@ class BrowserHTTPError(BrowserUnavailable):
pass
class BrowserSSLError(BrowserUnavailable):
pass
class ParseError(Exception):
pass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment