Secure boot is used to check the integrity of each component (driver loader, kernel, and kernel driver) during device startup. This prevents security threats to the system and user data caused by loading and running unauthenticated components.
Secure boot is a feature of the Unified Extensible Firmware Interface (UEFI) that requires all low-level firmware and software components to be verified before being loaded. During the boot process, UEFI secure boot checks the signature of each boot software, including the UEFI firmware driver (or option ROM), Extensible Firmware Interface (EFI) application, OS driver, and binary files. If the signature is valid or recognized by the original equipment manufacturer (OEM), the device will boot, and the firmware will hand over control to the OS.
UEFI is a standard that describes a new type of interface. It enables an OS to automatically load from a pre-boot operating environment to an OS.
The OSs that use the UEFI boot mode support secure boot. Secure boot provides verification of the boot chain status to ensure that only encrypted and verified UEFI binary files are executed after the firmware is initialized. These binary files include UEFI drivers, primary boot loaders, and chain loading components.
By default, secure boot is disabled and the system is in SetupMode. When the system is in SetupMode, all key variables can be updated without a cryptographic signature. After secure boot is enabled, the system exits SetupMode.
After secure boot is enabled, the system enforces signature validation on any UEFI binary files.
Secure boot uses key databases in a chain of trust, as shown in Table 1. These databases are stored in the UEFI variable storage.
Key Database |
Abbreviation |
Mandatory |
Description |
Format Constraints |
|---|---|---|---|---|
Platform key database |
PK |
Yes |
The PK database is the root of trust for the secure boot instance. The PK database contains a public PK key, which is used in the chain of trust to update the key exchange key (KEK) database. To change the PK database, you must have the private PK key to sign an update request. This includes deleting the PK database by writing an empty PK key. |
|
Key exchange key database |
KEK |
Yes |
The KEK database is a list of public KEK keys used in the chain of trust to update the signature (DB) and the revocation list (DBX) databases. The private KEK is used to add keys to the DB, which is a list of authorized signatures to be booted on the system. To change the public KEK database, you must have the private PK key to sign an update request. |
|
Signature database |
DB |
Yes |
The DB database is a list of public keys and hash values used in the chain of trust to verify all UEFI boot binary files. The DB list contains the authorized keys that are allowed to boot on the system. To modify the list, you must have a private KEK. To change the DB database, you must have either the private PK key or any of the private KEK keys to sign an update request. |
|
Forbidden signatures database |
DBX |
No |
The DBX database is a list of untrusted public keys and binary hashes used to revoke files in the chain of trust. The DBX database always takes precedence over all other key databases. To change the DBX database, you must have either the private PK key or any of the private KEK keys to sign an update request. You can obtain a publicly available DBX from the UEFI forum. For details, see Unified Extensible Firmware Interface Forum. |
|
Timestamp signatures database |
DBT |
No |
The DBT database retains the signature of the code in the timestamp signature database. |
|

You need to create keys based on the UEFI secure boot standard, create a certificate for each key, convert each certificate into a UEFI signature list (binary file), and sign each certificate using the related key.
Before creating a key pair, create a GUID for key generation.
uuidgen --random > GUID.txt
A PK is the root of trust for the UEFI secure boot instance.
openssl req -newkey rsa:4096 -nodes -keyout PK.key -new -x509 -sha256 -days 3650 -subj "/CN=Platform key/" -out PK.crt
Parameters in this command are described as follows:
openssl x509 -outform DER -in PK.crt -out PK.cer
cert-to-efi-sig-list -g "$(< GUID.txt)" PK.crt PK.esl
sign-efi-sig-list -g "$(< GUID.txt)" -k PK.key -c PK.crt PK PK.esl PK.auth
The private KEK is used to add keys to the signature database (DB), which is the list of authorized signatures to boot on the system.
openssl req -newkey rsa:4096 -nodes -keyout KEK.key -new -x509 -sha256 -days 3650 -subj "/CN=Key Exchange Key/" -out KEK.crt
openssl x509 -outform DER -in KEK.crt -out KEK.cer
cert-to-efi-sig-list -g "$(< GUID.txt)" KEK.crt KEK.esl
sign-efi-sig-list -g "$(< GUID.txt)" -k PK.key -c PK.crt KEK KEK.esl KEK.auth
The DB list contains the authorized keys that are allowed to boot on the system. To modify the list, you must have a private KEK.
Boot images will be signed with the private key that is created in this step.
openssl req -newkey rsa:4096 -nodes -keyout db.key -new -x509 -sha256 -days 3650 -subj "/CN=Signature Database key/" -out db.crt
openssl x509 -outform DER -in db.crt -out db.cer
cert-to-efi-sig-list -g "$(< GUID.txt)" db.crt db.esl
sign-efi-sig-list -g "$(< GUID.txt)" -k KEK.key -c KEK.crt db db.esl db.auth
The DBX disables specific DB certificates. It can be a certificate list or a hash list.
The DBT database signs signature timestamps. If the DB certificate is in the DBX and the DBX specifies the revocation time, the DB certificate can be used for signature verification only if the signature time is earlier than the revocation time.
For Ubuntu, sign the kernel file and boot file.
Preparations
Install the required package.
apt install sbsigntool efitools uuid-runtime -y
mkdir ~/certs cd ~/certs sudo sbsign --key db.key --cert db.crt --output /boot/vmlinuz-$(uname -r).signed /boot/vmlinuz-$(uname -r) # Replace the image file. mv /boot/vmlinuz-$(uname -r).signed /boot/vmlinuz-$(uname -r)
cd ~/certs sudo sbsign --key db.key --cert db.crt --output /boot/efi/EFI/ubuntu/grubx64.efi.signed /boot/efi/EFI/ubuntu/grubx64.efi sudo sbsign --key db.key --cert db.crt --output /boot/efi/EFI/ubuntu/shimx64.efi.signed /boot/efi/EFI/ubuntu/shimx64.efi sudo sbsign --key db.key --cert db.crt --output /boot/efi/EFI/ubuntu/mmx64.efi.signed /boot/efi/EFI/ubuntu/mmx64.efi # Replace the original file. sudo mv /boot/efi/EFI/ubuntu/grubx64.efi.signed /boot/efi/EFI/ubuntu/grubx64.efi sudo mv /boot/efi/EFI/ubuntu/shimx64.efi.signed /boot/efi/EFI/ubuntu/shimx64.efi sudo mv /boot/efi/EFI/ubuntu/mmx64.efi.signed /boot/efi/EFI/ubuntu/mmx64.efi
cp /boot/efi/EFI/ubuntu/shimx64.efi /boot/efi/EFI/BOOT/BOOTX64.EFI cp /boot/efi/EFI/ubuntu/grubx64.efi /boot/efi/EFI/BOOT/grubx64.efi cp /boot/efi/EFI/ubuntu/mmx64.efi /boot/efi/EFI/BOOT/mmx64.efi
Contact the image provider to obtain a secure boot certificate.
__platform_key=$(cat PK.cer | base64 -w 0)
__key_exchange_key=$(cat KEK.cer | base64 -w 0)
__signature_database=$(cat db.cer | base64 -w 0)
__forbidden_signatures_database=$(cat dbx.cer | base64 -w 0)
__timestamp_signatures_database=$(cat dbt.cer | base64 -w 0)
You can create a private image using IMS. For details, see Introduction.
You can call the following API to update the image metadata:
hw_firmware_type=uefi
__support_secure_boot=true
__platform_key=${__platform_key}
__key_exchange_key=${__key_exchange_key}
__signature_database=${__signature_database}
__forbidden_signatures_database=${__forbidden_signatures_database}
__timestamp_signatures_database=${__timestamp_signatures_database}
in the upper left corner and select a region and project.
in the upper left corner and select a region and project.For details about how to configure basic, network, and advanced settings when creating an ECS, see Overview.
If the value of Secure Boot State is Supported, UEFI secure boot is enabled.

mokutil --sb
