Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9f247ea

Browse files
committedMar 16, 2025·
T861: use custom Kernel certificate over the root shim signing certificate
1 parent df18ad0 commit 9f247ea

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
SIGN_FILE=$(find /usr/lib -name sign-file)
3-
MOK_KEY="/var/lib/shim-signed/mok/MOK.key"
4-
MOK_CERT="/var/lib/shim-signed/mok/MOK.pem"
3+
KERNEL_KEY="/var/lib/shim-signed/mok/vyos-dev-2025-linux.key"
4+
KERNEL_CERT="/var/lib/shim-signed/mok/vyos-dev-2025-linux.pem"
55
VMLINUZ=$(readlink /boot/vmlinuz)
66

77
# All Linux Kernel modules need to be cryptographically signed
@@ -13,10 +13,19 @@ find /lib/modules -type f -name \*.ko | while read MODULE; do
1313
fi
1414
done
1515

16-
if [ ! -f ${MOK_KEY} ]; then
16+
if [ ! -f ${KERNEL_KEY} ] && [ ! -f ${KERNEL_CERT} ]; then
1717
echo "I: Signing key for Linux Kernel not found - Secure Boot not possible"
1818
else
1919
echo "I: Signing Linux Kernel for Secure Boot"
20-
sbsign --key ${MOK_KEY} --cert ${MOK_CERT} /boot/${VMLINUZ} --output /boot/${VMLINUZ}
20+
sbsign --key ${KERNEL_KEY} --cert ${KERNEL_CERT} /boot/${VMLINUZ} --output /boot/${VMLINUZ}
2121
sbverify --list /boot/${VMLINUZ}
22+
rm -f ${KERNEL_KEY}
2223
fi
24+
25+
for cert in $(ls /var/lib/shim-signed/mok/); do
26+
if grep -rq "BEGIN PRIVATE KEY" /var/lib/shim-signed/mok/${cert}; then
27+
echo "Found private key - bailing out"
28+
exit 1
29+
fi
30+
done
31+

‎scripts/check-qemu-install

+11-1
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,16 @@ try:
398398

399399
loginVM(c, log)
400400

401+
#################################################
402+
# Check for no private key contents within the image
403+
#################################################
404+
msg = 'Found private key - bailing out'
405+
c.sendline(f'if sudo grep -rq "BEGIN PRIVATE KEY" /var/lib/shim-signed/mok; then echo {msg}; exit 1; fi')
406+
tmp = c.expect([f'\n{msg}', op_mode_prompt])
407+
if tmp == 0:
408+
log.error(msg)
409+
exit(1)
410+
401411
#################################################
402412
# Installing into VyOS system
403413
#################################################
@@ -879,7 +889,7 @@ except pexpect.exceptions.ExceptionPexpect:
879889
EXCEPTION = 1
880890

881891
except Exception:
882-
log.error('Unknown error occured while VyOS!')
892+
log.error('Unknown error occured!')
883893
traceback.print_exc()
884894
EXCEPTION = 1
885895

‎scripts/package-build/linux-kernel/build-kernel.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ sed -i -e "s/CN =.*/CN=VyOS build time autogenerated kernel key/" certs/default_
4141
TRUSTED_KEYS_FILE=trusted_keys.pem
4242
# start with empty key file
4343
echo -n "" > $TRUSTED_KEYS_FILE
44-
CERTS=$(find ../../../data/live-build-config/includes.chroot/var/lib/shim-signed/mok -name "*.pem" -type f || true)
44+
GIT_ROOT=$(git rev-parse --show-toplevel)
45+
CERTS=$(find ${GIT_ROOT}/data/certificates -name "*.pem" -type f || true)
4546
if [ ! -z "${CERTS}" ]; then
4647
# add known public keys to Kernel certificate chain
4748
for file in $CERTS; do

0 commit comments

Comments
 (0)
Please sign in to comment.