Skip to content

Commit b346d8d

Browse files
committed
Use pesign instead of sbsign
This more closely aligns with how kernel-uki-virt is signed today, and eliminates the requirement to use Fedora for the UKI toolchain. Subsequently, this also switches the UKI toolchain to use c10s. Signed-off-by: John Eckersberg <[email protected]>
1 parent b848577 commit b346d8d

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

Dockerfile.cfsuki

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
# Override via --build-arg=base=<image> to use a different base
22
ARG base=localhost/bootc
33
# This is where we get the tools to build the UKI
4-
ARG buildroot=quay.io/fedora/fedora:42
4+
ARG buildroot=quay.io/centos/centos:stream10
55
FROM $base AS base
66

77
FROM $buildroot as buildroot-base
88
RUN <<EORUN
99
set -xeuo pipefail
10-
dnf install -y systemd-ukify sbsigntools systemd-boot-unsigned
10+
11+
# systemd-udev is required for /usr/lib/systemd/systemd-measure which
12+
# is used by ukify as invoked with the `--measure` flag below. Not
13+
# strictly required, but nice to have the measured PCR values in the
14+
# output.
15+
dnf install -y systemd-ukify systemd-udev pesign openssl systemd-boot-unsigned
1116
dnf clean all
1217
EORUN
1318

@@ -28,25 +33,34 @@ RUN --mount=type=secret,id=key \
2833
# TODO: https://github.com/containers/composefs-rs/issues/183
2934
cmdline="composefs=${COMPOSEFS_FSVERITY} root=UUID=4f68bce3-e8cd-4db1-96e7-fbcaf984b709 console=ttyS0,115200n8 enforcing=0 rw"
3035

36+
# pesign uses NSS database so create it from input cert/key
37+
mkdir pesign
38+
certutil -N -d pesign --empty-password
39+
openssl pkcs12 -export -password 'pass:' -inkey /run/secrets/key -in /run/secrets/cert -out db.p12
40+
pk12util -i db.p12 -W '' -d pesign
41+
subject=$(openssl x509 -in /run/secrets/cert -subject | grep '^subject=CN=' | sed 's/^subject=CN=//')
42+
3143
kver=$(cd /target/usr/lib/modules && echo *)
3244
ukify build \
3345
--linux "/target/usr/lib/modules/$kver/vmlinuz" \
3446
--initrd "/target/usr/lib/modules/$kver/initramfs.img" \
3547
--uname="${kver}" \
3648
--cmdline "${cmdline}" \
3749
--os-release "@/target/usr/lib/os-release" \
38-
--signtool sbsign \
39-
--secureboot-private-key "/run/secrets/key" \
40-
--secureboot-certificate "/run/secrets/cert" \
50+
--signtool pesign \
51+
--secureboot-certificate-dir "pesign" \
52+
--secureboot-certificate-name "${subject}" \
4153
--measure \
4254
--json pretty \
4355
--output "/boot/$kver.efi"
4456
# Sign systemd-boot as well
4557
sdboot="/usr/lib/systemd/boot/efi/systemd-bootx64.efi"
46-
sbsign \
47-
--key "/run/secrets/key" \
48-
--cert "/run/secrets/cert" \
49-
"${sdboot}"
58+
pesign \
59+
--certdir "pesign" \
60+
--certificate "${subject}" \
61+
--in "${sdboot}" \
62+
--out "${sdboot}.signed" \
63+
--sign
5064
mv "${sdboot}.signed" "${sdboot}"
5165
EOF
5266

0 commit comments

Comments
 (0)