Allow multiple CERTHASH values in a module

Also fix typos and usage of reserved hash() function.
This commit is contained in:
Laurent Bachelier 2012-11-10 18:18:28 +01:00
commit 3eba9a809b
2 changed files with 6 additions and 4 deletions

View file

@ -37,7 +37,7 @@ __all__ = ['BNPorc']
class BNPorc(BaseBrowser):
DOMAIN = 'www.secure.bnpparibas.net'
PROTOCOL = 'https'
CERTHASH = 'f7dae8d9e0f2c63a1c35d8cf1a86fdd5441a897340538b045ba8197f40c28cad'
CERTHASH = ['f7dae8d9e0f2c63a1c35d8cf1a86fdd5441a897340538b045ba8197f40c28cad', '5511f0ff19c982b6351c17b901bfa7419f075edb13f2df41e446248beb7866bb']
ENCODING = None # refer to the HTML encoding
PAGES = {'.*pageId=unedescomptes.*': AccountsList,
'.*pageId=releveoperations.*': AccountHistory,

View file

@ -403,12 +403,14 @@ class StandardBrowser(mechanize.Browser):
except ControlNotFoundError:
return
def lowsslcheck(self, domain, hash):
def lowsslcheck(self, domain, hsh):
certs = ssl.get_server_certificate((domain, 443))
certhash = hashlib.sha256(certs).hexdigest()
if self.logger:
self.logger.debug('Found %s as certificat hash' % certhash)
if certhash != hash:
self.logger.debug('Found %s as certificate hash' % certhash)
if isinstance(hsh, basestring):
hsh = [hsh]
if certhash not in hsh:
raise ssl.SSLError()