MCPcopy
hub / github.com/HelloZeroNet/ZeroNet / verifyCert

Method verifyCert

src/Content/ContentManager.py:798–828  ·  view source on GitHub ↗
(self, inner_path, content)

Source from the content-addressed store, hash-verified

796 return 1 # Todo: Multisig
797
798 def verifyCert(self, inner_path, content):
799 from Crypt import CryptBitcoin
800
801 rules = self.getRules(inner_path, content)
802
803 if not rules:
804 raise VerifyError("No rules for this file")
805
806 if not rules.get("cert_signers") and not rules.get("cert_signers_pattern"):
807 return True # Does not need cert
808
809 if "cert_user_id" not in content:
810 raise VerifyError("Missing cert_user_id")
811
812 if content["cert_user_id"].count("@") != 1:
813 raise VerifyError("Invalid domain in cert_user_id")
814
815 name, domain = content["cert_user_id"].rsplit("@", 1)
816 cert_address = rules["cert_signers"].get(domain)
817 if not cert_address: # Unknown Cert signer
818 if rules.get("cert_signers_pattern") and SafeRe.match(rules["cert_signers_pattern"], domain):
819 cert_address = domain
820 else:
821 raise VerifyError("Invalid cert signer: %s" % domain)
822
823 try:
824 cert_subject = "%s#%s/%s" % (rules["user_address"], content["cert_auth_type"], name)
825 result = CryptBitcoin.verify(cert_subject, cert_address, content["cert_sign"])
826 except Exception as err:
827 raise VerifyError("Certificate verify error: %s" % err)
828 return result
829
830 # Checks if the content.json content is valid
831 # Return: True or False

Callers 2

verifyFileMethod · 0.95
testCertMethod · 0.80

Calls 5

getRulesMethod · 0.95
VerifyErrorClass · 0.85
verifyMethod · 0.80
getMethod · 0.45
countMethod · 0.45

Tested by 1

testCertMethod · 0.64