5.5. 使用 Google Cloud Platform 上的自定义 RHEL 镜像中的安全引导机制配置 RHEL 实例


以下流程通过将自定义证书包含在 SecureBoot DB 中来配置 RHEL 实例,这可让您为自定义工件签名,如第三方内核模块和 UKI 扩展。

先决条件

流程

  1. 创建新的随机通用唯一标识符(UUID),并将其存储在生成的随机文本文件中:

    $ uuidgen --random > GUID.txt
  2. 为平台密钥数据库生成一个新的 RSA 私钥 PK.key 和自签名 X.509 证书 PK.cer

    $ openssl req -quiet -newkey rsa:4096 -nodes -keyout PK.key -new -x509 -sha256 -days 3650 -subj "/CN=Platform key/" -outform DER -out PK.cer

    openssl 工具通过将输出格式设置为 Distinguished Encoding Rules (DNR)来为证书生成一个通用名称 平台密钥。DNR 是数据编码的标准化二进制格式。

  3. 为密钥交换密钥数据库生成一个新的 RSA 私钥 KEK.key 和自签名 X.509 证书 KEK.cer

    $ openssl req -quiet -newkey rsa:4096 -nodes -keyout KEK.key -new -x509 -sha256 -days 3650 -subj "/CN=Key Exchange Key/" -outform DER -out KEK.cer
  4. 生成自定义证书 custom_db.cer

    $ openssl req -quiet -newkey rsa:4096 -nodes -keyout custom_db.key -new -x509 -sha256 -days 3650 -subj "/CN=Signature Database key/" --outform DER -out custom_db.cer
  5. 下载 Microsoft 证书:

    $ wget https://go.microsoft.com/fwlink/p/?linkid=321194 --user-agent="Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" -O MicCorUEFCA2011_2011-06-27.crt
  6. 为 64 位系统下载更新的禁止签名(dbx) UEFI Revocation List 文件:

    $ wget https://uefi.org/sites/default/files/resources/x64_DBXUpdate.bin
  7. 使用 google-cloud-cli 工具在磁盘分区中创建镜像并将其注册到所需的安全引导变量:

    $ gcloud compute images create <example-rhel-9-efi-image> --source-image projects/<example_project_id>/global/images/<example_image_name> --platform-key-file=PK.cer --key-exchange-key-file=KEK.cer --signature-database-file=custom_db.cer,MicCorUEFCA2011_2011-06-27.crt --forbidden-database-file x64_DBXUpdate.bin --guest-os-features="UEFI_COMPATIBLE"
  8. 使用 Google Cloud 控制台 打开安全引导 功能来启动 example-rhel-9-efi-image 镜像的实例。

    gcp secure boot

验证

  1. 检查新创建的 RHEL 实例是否启用了安全引导机制:

    $ mokutil --sb-state
    SecureBoot enabled
  2. 使用 keyctl 工具验证自定义证书的内核密钥环:

    $ sudo keyctl list %:.platform
    ...
    757453569: ---lswrv     0     0 asymmetric: Signature Database key: f064979641c24e1b935e402bdbc3d5c4672a1acc
    ...
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.