Fix unhandled expcetion on invalid cert
This commit is contained in:
parent
1ee592f5b7
commit
4c7ff9bb53
2 changed files with 9 additions and 4 deletions
|
@ -658,9 +658,14 @@ class ContentManager(object):
|
||||||
if not cert_address: # Cert signer not allowed
|
if not cert_address: # Cert signer not allowed
|
||||||
self.log.warning("Invalid cert signer: %s" % domain)
|
self.log.warning("Invalid cert signer: %s" % domain)
|
||||||
return False
|
return False
|
||||||
return CryptBitcoin.verify(
|
|
||||||
"%s#%s/%s" % (rules["user_address"], content["cert_auth_type"], name), cert_address, content["cert_sign"]
|
try:
|
||||||
)
|
cert_subject = "%s#%s/%s" % (rules["user_address"], content["cert_auth_type"], name)
|
||||||
|
result = CryptBitcoin.verify(cert_subject, cert_address, content["cert_sign"])
|
||||||
|
except Exception, err:
|
||||||
|
self.log.warning("Certificate verify error: %s" % err)
|
||||||
|
result = False
|
||||||
|
return result
|
||||||
|
|
||||||
# Checks if the content.json content is valid
|
# Checks if the content.json content is valid
|
||||||
# Return: True or False
|
# Return: True or False
|
||||||
|
|
|
@ -331,7 +331,7 @@ def verify_message(address, signature, message):
|
||||||
def SetCompactSignature(pkey, hash, signature):
|
def SetCompactSignature(pkey, hash, signature):
|
||||||
sig = base64.b64decode(signature)
|
sig = base64.b64decode(signature)
|
||||||
if len(sig) != 65:
|
if len(sig) != 65:
|
||||||
raise BaseException("Wrong encoding")
|
raise Exception("Wrong encoding")
|
||||||
nV = ord(sig[0])
|
nV = ord(sig[0])
|
||||||
if nV < 27 or nV >= 35:
|
if nV < 27 or nV >= 35:
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in a new issue