mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 22:24:23 +01:00
Minor fixes
This commit is contained in:
@@ -118,7 +118,7 @@ def add_appointment(args):
|
|||||||
logger.error("The response does not contain the signature of the appointment.")
|
logger.error("The response does not contain the signature of the appointment.")
|
||||||
else:
|
else:
|
||||||
# verify that the returned signature is valid
|
# 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.")
|
logger.error("The returned appointment's signature is invalid.")
|
||||||
else:
|
else:
|
||||||
if 'error' not in response_json:
|
if 'error' not in response_json:
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ def add_appointment():
|
|||||||
if type(appointment) == Appointment:
|
if type(appointment) == Appointment:
|
||||||
appointment_added, signature = watcher.add_appointment(appointment)
|
appointment_added, signature = watcher.add_appointment(appointment)
|
||||||
|
|
||||||
# ToDo: #13-create-server-side-signature-receipt
|
|
||||||
if appointment_added:
|
if appointment_added:
|
||||||
rcode = HTTP_OK
|
rcode = HTTP_OK
|
||||||
response = {
|
response = {
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ class Watcher:
|
|||||||
raise ValueError("No signing key provided. Please fix your pisa.conf")
|
raise ValueError("No signing key provided. Please fix your pisa.conf")
|
||||||
else:
|
else:
|
||||||
with open(PISA_SECRET_KEY, "r") as key_file:
|
with open(PISA_SECRET_KEY, "r") as key_file:
|
||||||
privkey_pem = key_file.read().encode("utf-8")
|
secret_key_pem = key_file.read().encode("utf-8")
|
||||||
self.signing_key = load_pem_private_key(privkey_pem, password=None, backend=default_backend())
|
self.signing_key = load_pem_private_key(secret_key_pem, password=None, backend=default_backend())
|
||||||
|
|
||||||
def add_appointment(self, appointment):
|
def add_appointment(self, appointment):
|
||||||
# Rationale:
|
# Rationale:
|
||||||
@@ -73,7 +73,6 @@ class Watcher:
|
|||||||
|
|
||||||
logger.info("New appointment accepted.", locator=appointment.locator)
|
logger.info("New appointment accepted.", locator=appointment.locator)
|
||||||
|
|
||||||
print(appointment.to_json().encode("utf-8"))
|
|
||||||
signature = self.signing_key.sign(
|
signature = self.signing_key.sign(
|
||||||
appointment.to_json().encode("utf-8"),
|
appointment.to_json().encode("utf-8"),
|
||||||
ec.ECDSA(hashes.SHA256())
|
ec.ECDSA(hashes.SHA256())
|
||||||
|
|||||||
Reference in New Issue
Block a user