Skip to content

Commit 79c9798

Browse files
authored
Merge pull request #824 from jettero/4.0-polishing-signing
4.0 polishing signing
2 parents 41fa0a2 + 4dc2328 commit 79c9798

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

hubblestack/utils/signing.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,10 @@ def verify_signature(fname, sfname, public_crt='public.crt', ca_crt='ca-root.crt
467467
return STATUS.VERIFIED if both the signature and the CA sig match
468468
"""
469469
log_level = log.debug
470+
if fname is None or sfname is None:
471+
status = STATUS.UNKNOWN
472+
log_level('fname=%s or sfname=%s is Nones => status=%s', fname, sfname, status)
473+
return status
470474
short_fname = fname.split('/')[-1]
471475
try:
472476
with open(sfname, 'r') as fh:
@@ -477,7 +481,7 @@ def verify_signature(fname, sfname, public_crt='public.crt', ca_crt='ca-root.crt
477481
if check_verif_timestamp(verif_key):
478482
log_level = log.error
479483
log_level('%s | file "%s" | status: %s ', short_fname, fname, status)
480-
return STATUS.UNKNOWN
484+
return status
481485
x509 = X509AwareCertBucket(public_crt, ca_crt)
482486
hasher, chosen_hash = hash_target(fname, obj_mode=True)
483487
digest = hasher.finalize()
@@ -535,8 +539,14 @@ def verify_files(targets, mfname='MANIFEST', sfname='SIGNATURE', public_crt='pub
535539
return a mapping from the input target list to the status values (a dict of filename: status)
536540
"""
537541

542+
if mfname is None:
543+
mfname = 'MANIFEST'
544+
if sfname is None:
545+
sfname = 'SIGNATURE'
546+
538547
log.debug("verifying: files: %s | mfname: %s | sfname: %s | public_crt: %s| ca_crt: %s",
539548
targets, mfname, sfname, public_crt, ca_crt)
549+
540550
ret = OrderedDict()
541551
ret[mfname] = verify_signature(mfname, sfname=sfname, public_crt=public_crt, ca_crt=ca_crt)
542552
# ret[mfname] is the strongest claim we can make about the files we're

0 commit comments

Comments
 (0)