summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2021-03-17 14:37:18 +0200
committerYuval Adam <_@yuv.al>2021-03-17 14:37:18 +0200
commitf24e2789d7b6ad195765674f130d13c68dca6a45 (patch)
treed0a08c3bcb39e9e00911dab6606cacdbda9d0d90
parent8db980b2624966744dd8a18d6ed70ba5447a2d6d (diff)
Fix pdf loading and small bugs
-rw-r--r--verify.py11
1 files changed, 7 insertions, 4 deletions
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()