Skip to content

Commit bf35f9c

Browse files
authored
ukify: fix handling of --secureboot-certificate-validity= (#30315)
Before: $ python src/ukify/ukify.py genkey --secureboot-private-key=sb2.key --secureboot-certificate=sb2.cert --secureboot-certificate-validity=111 Traceback (most recent call last): File "/home/zbyszek/src/systemd-work/src/ukify/ukify.py", line 1660, in <module> main() File "/home/zbyszek/src/systemd-work/src/ukify/ukify.py", line 1652, in main generate_keys(opts) File "/home/zbyszek/src/systemd-work/src/ukify/ukify.py", line 943, in generate_keys key_pem, cert_pem = generate_key_cert_pair( ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/zbyszek/src/systemd-work/src/ukify/ukify.py", line 891, in generate_key_cert_pair now + ONE_DAY * valid_days ~~~~~~~~^~~~~~~~~~~~ TypeError: can't multiply sequence by non-int of type 'datetime.timedelta' Now: $ python src/ukify/ukify.py genkey --secureboot-private-key=sb2.key --secureboot-certificate=sb2.cert --secureboot-certificate-validity=111 Writing SecureBoot private key to sb2.key Writing SecureBoot certificate to sb2.cert The new code is also clearer.
1 parent 9f08d7f commit bf35f9c

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/ukify/ukify.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -846,8 +846,6 @@ def make_uki(opts):
846846
print(f"Wrote {'signed' if sign_args_present else 'unsigned'} {opts.output}")
847847

848848

849-
ONE_DAY = datetime.timedelta(1, 0, 0)
850-
851849

852850
@contextlib.contextmanager
853851
def temporary_umask(mask: int):
@@ -888,7 +886,7 @@ def generate_key_cert_pair(
888886
).not_valid_before(
889887
now,
890888
).not_valid_after(
891-
now + ONE_DAY * valid_days
889+
now + datetime.timedelta(days=valid_days)
892890
).serial_number(
893891
x509.random_serial_number()
894892
).public_key(
@@ -1335,6 +1333,7 @@ def config_example(self) -> tuple[Optional[str], Optional[str], Optional[str]]:
13351333
ConfigItem(
13361334
'--secureboot-certificate-validity',
13371335
metavar = 'DAYS',
1336+
type = int,
13381337
dest = 'sb_cert_validity',
13391338
default = 365 * 10,
13401339
help = "period of validity (in days) for a certificate created by 'genkey'",

0 commit comments

Comments
 (0)