Skip to content

Commit

Permalink
Modified: sign record func now returns signature along with record (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
signebedi committed Mar 26, 2024
1 parent 9ff0b2a commit 85f5db4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions libreforms_fastapi/utils/certificates.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def ensure_key_storage(self):
os.makedirs(self.key_storage_path)

def get_private_key_file(self):

if self.private_key_path:
return self.private_key_path

Expand Down Expand Up @@ -201,8 +201,9 @@ def sign_record(record, username, env="development"):
ds_manager = DigitalSignatureManager(username=username, env=env)
serialized = serialize_record_for_signing(record)
signature = ds_manager.sign_data(serialized.encode())
record['metadata']['_signature'] = signature.hex() # Store the signature as a hex string
return record
s = signature.hex()
record['metadata']['_signature'] = s # Store the signature as a hex string
return record, s

def verify_record_signature(record, username, env="development", public_key=None):
"""
Expand Down

0 comments on commit 85f5db4

Please sign in to comment.