opencomputeproject / onie

Open Network Install Environment
https://opencomputeproject.github.io/onie
Other
606 stars 376 forks source link

unsecure onie to secure onie signed by efitools and sbsigntools #1021

Closed fiveshit closed 1 year ago

fiveshit commented 1 year ago

I built a unsecure onie and I want to use efitools and sbsigntools to sign it. Is it possible? First I generate keys as below

openssl req -new -x509 -newkey rsa:2048 -subj "/CN=$NAME PK/" -keyout PK.key \
        -out PK.crt -days 3650 -nodes -sha256
openssl req -new -x509 -newkey rsa:2048 -subj "/CN=$NAME KEK/" -keyout KEK.key \
        -out KEK.crt -days 3650 -nodes -sha256
openssl req -new -x509 -newkey rsa:2048 -subj "/CN=$NAME DB/" -keyout DB.key \
        -out DB.crt -days 3650 -nodes -sha256
openssl x509 -in PK.crt -out PK.cer -outform DER
openssl x509 -in KEK.crt -out KEK.cer -outform DER
openssl x509 -in DB.crt -out DB.cer -outform DER

GUID=`python3 -c 'import uuid; print(str(uuid.uuid1()))'`echo 
$GUID > myGUID.txt

cert-to-efi-sig-list -g $GUID PK.crt PK.esl
cert-to-efi-sig-list -g $GUID KEK.crt KEK.esl
cert-to-efi-sig-list -g $GUID DB.crt DB.esl
rm -f noPK.esl
touch noPK.esl

sign-efi-sig-list -t "$(date --date='1 second' +'%Y-%m-%d %H:%M:%S')" \
                  -k PK.key -c PK.crt PK PK.esl PK.auth
sign-efi-sig-list -t "$(date --date='1 second' +'%Y-%m-%d %H:%M:%S')" \
                  -k PK.key -c PK.crt PK noPK.esl noPK.auth
sign-efi-sig-list -t "$(date --date='1 second' +'%Y-%m-%d %H:%M:%S')" \
                  -k PK.key -c PK.crt KEK KEK.esl KEK.auth
sign-efi-sig-list -t "$(date --date='1 second' +'%Y-%m-%d %H:%M:%S')" \
                  -k KEK.key -c KEK.crt db DB.esl DB.auth
chmod 0600 *.key

And I installed keys to BIOS and signed grubx64.efi

efi-updatevar -f DB.auth db
efi-updatevar -f KEK.auth KEK
efi-updatevar -f PK.auth PK
sbsign --key DB.key --cert DB.crt /boot/EFI/onie/grubx64.efi --output /boot/EFI/onie/grubx64.efi

finished. But I will stopped grub console show msg " error secure boot forbids loading module from (hd0,gpt2)/grub/x86_64.efi/normal.mod"