MCPcopy Create free account
hub / github.com/comaps/comaps / sign_file

Function sign_file

tools/python/maps_generator/utils/file.py:209–224  ·  view source on GitHub ↗
(file_path, key_path, signature_path=None)

Source from the content-addressed store, hash-verified

207
208
209def sign_file(file_path, key_path, signature_path=None):
210 if signature_path is None:
211 signature_path = file_path + ".sig"
212 cmd = [
213 "openssl", "pkeyutl", "-sign",
214 "-inkey", key_path,
215 "-rawin", "-in", file_path,
216 "-out", signature_path,
217 ]
218 proc = subprocess.run(cmd, capture_output=True, text=True)
219 if proc.returncode != 0:
220 stderr = proc.stderr.strip()
221 stdout = proc.stdout.strip()
222 raise SigningError(f"Signing {file_path} with {key_path} failed (exitcode: {proc.returncode} stdout: {stdout!s} stderr: {stderr!s}")
223 logger.info(f"Signed {file_path}, signature {signature_path}")
224 return signature_path
225
226
227def verify_file(file_path, signature_path, pub_key_path):

Callers 2

applyMethod · 0.90

Calls 2

SigningErrorClass · 0.90
runMethod · 0.45

Tested by

no test coverage detected