]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ukify: ellipsize CN to not exceed maximum length
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 2 Dec 2024 13:42:23 +0000 (14:42 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 2 Dec 2024 16:55:57 +0000 (16:55 +0000)
Currently the generation of the certificate fails if len(fqdn) >= 43.
Ellipsize the fqdn to let the tests pass in all cases.

Fixes https://github.com/systemd/systemd/issues/34581.

src/ukify/ukify.py

index a5719615cc3fe307943cef45c710964ba0891316..e661dfe5485d5fc9b961143eee3ba684f8b0cab9 100755 (executable)
@@ -1387,7 +1387,12 @@ def generate_keys(opts: UkifyConfig) -> None:
     # are specified as input paths.
     if opts.sb_key and opts.sb_cert:
         fqdn = socket.getfqdn()
+
         cn = f'SecureBoot signing key on host {fqdn}'
+        if len(cn) > 64:
+            # The length of CN must not exceed 64 bytes
+            cn = cn[:61] + '...'
+
         key_pem, cert_pem = generate_key_cert_pair(
             common_name=cn,
             valid_days=opts.sb_cert_validity,