From f24e2789d7b6ad195765674f130d13c68dca6a45 Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Wed, 17 Mar 2021 14:37:18 +0200 Subject: Fix pdf loading and small bugs --- verify.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'verify.py') diff --git a/verify.py b/verify.py index cb57405..45289e2 100644 --- a/verify.py +++ b/verify.py @@ -26,7 +26,7 @@ class GreenPassVerifier(object): self.cert = self.get_cert_path("RamzorQRPubKey.pem") @classmethod - def from_txt(cls, path): + def from_payload(cls, path): with open(path, "rb") as f: return cls(f.read().strip()) @@ -46,10 +46,11 @@ class GreenPassVerifier(object): ): img = fitz.Pixmap(doc, xref) data = img.getImageData(output="png") - return cls(BytesIO(data)) + return cls.from_qr(BytesIO(data)) def validate_data(self): - if self.data["ct"] not in (1, 2): + ct = self.data["ct"] + if ct not in (1, 2): raise Exception(f"Unsupported certificate type ct={ct}") def get_cert_path(self, name): @@ -60,7 +61,7 @@ class GreenPassVerifier(object): data = self.data if data["ct"] == 1: for i in range(len(data["p"])): - self.details.append( + details.append( { "id_num": data["p"][i]["idl"], "valid_by": data["p"][i]["e"], @@ -133,6 +134,8 @@ def verify_cmd(pdf_path="", image_path="", txt_path=""): click.echo(ctx.get_help()) ctx.exit() + verifier.verify() + if __name__ == "__main__": verify_cmd() -- cgit v1.3.1