Secure Boot and custom certificates

Let's say you have a laptop with Windows installed on it by its manufacturer (so called OEM version). You want to keep Secure Boot enabled, but you also want to boot some custom Linux from USB drive or through the network via PXE.

Secure Boot Enabled

You need to sign a kernel, otherwise you get this error

bzImage has invalid signature

You normally would follow instructions like this https://ubuntu.com/blog/how-to-sign-things-for-secure-boot, where new signature is installed by mokutil, but you are on Windows right now.

According to Eclypsium in https://eclypsium.com/2020/07/29/theres-a-hole-in-the-boot/ there is Kaspersky Rescue Disk 18 https://support.kaspersky.com/krd18 that bypasses Secure Boot. Official build is hardened with signatures, but hacky version still can be found online (https://usbtor.ru/viewtopic.php?p=65909). It will work only if you don't update your Windows (since somewhere like 2020), because UEFI Forum already have this bootloader in the revocation list (https://uefi.org/revocationlistfile)

Probably a great article http://www.rodsbooks.com/efi-bootloaders/secureboot.html, but good God Roderick W. Smith, I fall asleep after each paragraph, I don't know which note is important, I read information and don't know how to apply it.

Packages to your system

  • sbsigntools

  • pesign

Add to ESP partition

  • public key (for MOK),

  • shimx64.efi (Secure boot solution from Matthew J. Garrett),

  • mmx64.efi (mm stands for MOK Manager),

  • grubx64.efi (GRUB 2)

Where to get this files?

Following tutorial from https://doc.opensuse.org/documentation/leap/reference/html/book-reference/cha-uefi.html

Getting an error

Later I realized (https://github.com/rhboot/pesign/issues/64) that my kernel should have CONFIG_EFI_STUB enabled https://www.kernel.org/doc/html/latest/admin-guide/efi-stub.html

Finding another tutorials

And trying

And getting an error

Invalid DOS header magic

Sign the kernel

How to compile grubx64.efi

bug https://savannah.gnu.org/bugs/index.php?55636

https://github.com/rhboot/grub2/pull/82

https://bugzilla.redhat.com/show_bug.cgi?id=1809246

https://www.gnu.org/software/grub/grub-download.html

git clone https://git.savannah.gnu.org/git/grub.git

patch

https://lists.gnu.org/archive/html/grub-devel/2014-04/msg00091.html

Last updated

Was this helpful?