ukify: fix handling of --secureboot-certificate-validity= (#30315)
authorRoland Singer <roland.singer@desertbit.com>
Wed, 6 Dec 2023 09:49:47 +0000 (10:49 +0100)
committerGitHub <noreply@github.com>
Wed, 6 Dec 2023 09:49:47 +0000 (10:49 +0100)
commitbf35f9c83541785726dce41e54496a07f4841621
tree8449db3fcc6cf5bbd791b23622b59b9fe3b9b6aa
parent9f08d7f777e4e92d50de3df11a598ec01246bf72
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.
src/ukify/ukify.py