From 9b1af92fc326c69337d2a5ff031547b3d7236a67 Mon Sep 17 00:00:00 2001 From: Salvatore Ingala <6681844+bigspider@users.noreply.github.com> Date: Tue, 22 Oct 2019 18:59:27 +0800 Subject: [PATCH] Minor fixes --- apps/cli/pisa-cli.py | 2 +- pisa/api.py | 1 - pisa/watcher.py | 5 ++--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/cli/pisa-cli.py b/apps/cli/pisa-cli.py index 03b9445..a9b9c49 100644 --- a/apps/cli/pisa-cli.py +++ b/apps/cli/pisa-cli.py @@ -118,7 +118,7 @@ def add_appointment(args): logger.error("The response does not contain the signature of the appointment.") else: # verify that the returned signature is valid - if is_appointment_signature_valid(appointment, response_json['signature']) == False: + if not is_appointment_signature_valid(appointment, response_json['signature']): logger.error("The returned appointment's signature is invalid.") else: if 'error' not in response_json: diff --git a/pisa/api.py b/pisa/api.py index 90940a8..55b94b6 100644 --- a/pisa/api.py +++ b/pisa/api.py @@ -38,7 +38,6 @@ def add_appointment(): if type(appointment) == Appointment: appointment_added, signature = watcher.add_appointment(appointment) - # ToDo: #13-create-server-side-signature-receipt if appointment_added: rcode = HTTP_OK response = { diff --git a/pisa/watcher.py b/pisa/watcher.py index 65058d3..8b4cd34 100644 --- a/pisa/watcher.py +++ b/pisa/watcher.py @@ -31,8 +31,8 @@ class Watcher: raise ValueError("No signing key provided. Please fix your pisa.conf") else: with open(PISA_SECRET_KEY, "r") as key_file: - privkey_pem = key_file.read().encode("utf-8") - self.signing_key = load_pem_private_key(privkey_pem, password=None, backend=default_backend()) + secret_key_pem = key_file.read().encode("utf-8") + self.signing_key = load_pem_private_key(secret_key_pem, password=None, backend=default_backend()) def add_appointment(self, appointment): # Rationale: @@ -73,7 +73,6 @@ class Watcher: logger.info("New appointment accepted.", locator=appointment.locator) - print(appointment.to_json().encode("utf-8")) signature = self.signing_key.sign( appointment.to_json().encode("utf-8"), ec.ECDSA(hashes.SHA256())