7.13. 配置信任值、策略和 secret


您可以为 Trustee 配置以下值、策略和 secret:

  • 可选:参考值提供程序服务的引用值。
  • 可选: 验证策略。
  • 为 Intel Trust Domain Extensions (TDX)置备证书缓存服务。
  • 可选: Trustee 客户端的自定义密钥的 Secret。
  • 可选:用于容器镜像签名验证的 Secret。
  • 容器镜像签名验证策略。这个策略是必需的。如果不使用容器镜像签名验证,您必须创建一个不验证签名的策略。
  • 资源访问策略。

7.13.1. 配置参考值

您可以通过指定硬件平台的可信摘要来配置参考值。

客户端从正在运行的软件、受信任的执行环境(TEE)硬件和固件中收集测量,并将声明中的引用提交到 Attestation Server。这些测量必须与注册到 Trustee 的可信摘要匹配。此过程可确保机密虚拟机(CVM)正在运行预期的软件堆栈,并且未被篡改。

流程

  1. 创建 rvps-configmap.yaml 清单文件:

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: rvps-reference-values
      namespace: trustee-operator-system
    data:
      reference-values.json: |
        [ 
    1
    
        ]
    Copy to Clipboard Toggle word wrap
    1
    如果需要,为您的硬件平台指定可信摘要。否则,将它留空。
  2. 运行以下命令来创建 RVPS 配置映射:

    $ oc apply -f rvps-configmap.yaml
    Copy to Clipboard Toggle word wrap

7.13.2. 创建 attestation 策略

您可以创建一个 attestation 策略来覆盖默认的 attestation 策略。

流程

  1. 根据以下示例创建 attestation-policy.yaml 清单文件:

    # attestation-policy.yaml
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: attestation-policy
      namespace: trustee-operator-system
    data:
      default.rego: |
        package policy
    
        import rego.v1
    
        # This policy validates multiple TEE platforms
        # The policy is meant to capture the TCB requirements
        # for confidential containers.
    
        # This policy is used to generate an EAR Appraisal.
        # More information can be found at
        # <https://datatracker.ietf.org/doc/draft-ietf-rats-ar4si/>
    
        default executables := 33
    
        default hardware := 97
    
        default configuration := 36
    
        executables := 3 if {
          input.sample.launch_digest in data.reference.launch_digest
        }
    
        hardware := 2 if {
          input.sample.svn in data.reference.svn
        }
    
        executables := 3 if {
          input.snp.measurement in data.reference.snp_launch_measurement
        }
    
        hardware := 2 if {
          input.snp.reported_tcb_bootloader in data.reference.snp_bootloader
          input.snp.reported_tcb_microcode in data.reference.snp_microcode
          input.snp.reported_tcb_snp in data.reference.snp_snp_svn
          input.snp.reported_tcb_tee in data.reference.snp_tee_svn
        }
    
        configuration := 2 if {
          input.snp.policy_debug_allowed == "0"
          input.snp.policy_migrate_ma == "0"
          input.snp.platform_smt_enabled in data.reference.snp_smt_enabled
          input.snp.platform_tsme_enabled in data.reference.snp_tsme_enabled
          input.snp.policy_abi_major in data.reference.snp_guest_abi_major
          input.snp.policy_abi_minor in data.reference.snp_guest_abi_minor
          input.snp.policy_single_socket in data.reference.snp_single_socket
          input.snp.policy_smt_allowed in data.reference.snp_smt_allowed
        }
    
        else := 3 if {
          input.snp.policy_debug_allowed == "0"
          input.snp.policy_migrate_ma == "0"
        }
    
        executables := 3 if {
          input.tdx.quote.body.rtmr_1 in data.reference.rtmr_1
          input.tdx.quote.body.rtmr_2 in data.reference.rtmr_2
        }
    
        hardware := 2 if {
          # Check that this is a TDX quote signed by the Intel SGX Quoting Enclave.
          input.tdx.quote.header.tee_type == "81000000"
          input.tdx.quote.header.vendor_id == "939a7233f79c4ca9940a0db3957f0607"
    
          # Check TDX Module version and its hash. Also check OVMF code hash.
          input.tdx.quote.body.mr_seam in data.reference.mr_seam
          input.tdx.quote.body.tcb_svn in data.reference.tcb_svn
          input.tdx.quote.body.mr_td in data.reference.mr_td
          # Check TCB status
          # input.tdx.tcb_status == "OK"
    
          # Check collateral expiration status
          # input.tdx.collateral_expiration_status == "0"
    
          # Check against allowed advisory ids
          # allowed_advisory_ids := {"INTEL-SA-00837"}
          # attester_advisory_ids := {id | id := input.attester_advisory_ids[_]}
          # object.subset(allowed_advisory_ids, attester_advisory_ids)
    
          # Check against disallowed advisory ids
          # disallowed_advisory_ids := {"INTEL-SA-00837"}
          # attester_advisory_ids := {id | id := input.tdx.advisory_ids[_]} # convert array to set
          # intersection := attester_advisory_ids & disallowed_advisory_ids
          # count(intersection) == 0
        }
    
        configuration := 2 if {
          input.tdx.td_attributes.debug == false
          input.tdx.quote.body.xfam in data.reference.xfam
        }
    
        executables := 3 if {
          input.azsnpvtpm.measurement in data.reference.measurement
          input.azsnpvtpm.tpm.pcr11 in data.reference.snp_pcr11
        }
    
        hardware := 2 if {
          input.azsnpvtpm.reported_tcb_bootloader in data.reference.tcb_bootloader
          input.azsnpvtpm.reported_tcb_microcode in data.reference.tcb_microcode
          input.azsnpvtpm.reported_tcb_snp in data.reference.tcb_snp
          input.azsnpvtpm.reported_tcb_tee in data.reference.tcb_tee
        }
    
        configuration := 2 if {
          input.azsnpvtpm.platform_smt_enabled in data.reference.smt_enabled
          input.azsnpvtpm.platform_tsme_enabled in data.reference.tsme_enabled
          input.azsnpvtpm.policy_abi_major in data.reference.abi_major
          input.azsnpvtpm.policy_abi_minor in data.reference.abi_minor
          input.azsnpvtpm.policy_single_socket in data.reference.single_socket
          input.azsnpvtpm.policy_smt_allowed in data.reference.smt_allowed
        }
    
        ##### Azure vTPM TDX
        executables := 3 if {
          input.aztdxvtpm.tpm.pcr11 in data.reference.tdx_pcr11
        }
    
        hardware := 2 if {
          # Check that the quote is a TDX quote signed by the Intel SGX Quoting Enclave.
          input.aztdxvtpm.quote.header.tee_type == "81000000"
          input.aztdxvtpm.quote.header.vendor_id == "939a7233f79c4ca9940a0db3957f0607"
    
          # Check TDX Module version and its hash. Also check OVMF code hash.
          input.aztdxvtpm.quote.body.mr_seam in data.reference.mr_seam
          input.aztdxvtpm.quote.body.tcb_svn in data.reference.tcb_svn
          input.aztdxvtpm.quote.body.mr_td in data.reference.mr_td
        }
    
        configuration := 2 if {
          input.aztdxvtpm.quote.body.xfam in data.reference.xfam
        }
    Copy to Clipboard Toggle word wrap

    attestation 策略遵循 Open Policy Agent 规格。在本例中,attestation 策略将 attestation 报告中提供的声明与 RVPS 数据库中注册的引用值进行比较。只有所有值都匹配时才会成功 attestation 进程。

  2. 运行以下命令来创建 attestation 策略配置映射:

    $ oc apply -f attestation-policy.yaml
    Copy to Clipboard Toggle word wrap

7.13.3. 为 TDX 配置 PCCS

如果使用 Intel Trust Domain Extensions (TDX),您必须将 Trustee 配置为使用 Provisioning Certificate Caching Service (PCCS)。

PCCS 检索配置认证密钥(PCK)证书,并将其缓存在本地数据库中。

重要

不要使用公共 Intel PCCS 服务。在内部或公共云中使用本地缓存服务。

流程

  1. 根据以下示例创建 tdx-config.yaml 清单文件:

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: tdx-config
      namespace: trustee-operator-system
    data:
      sgx_default_qcnl.conf: | \
          {
            "collateral_service": "https://api.trustedservices.intel.com/sgx/certification/v4/",
            "pccs_url": "<pccs_url>" 
    1
    
          }
    Copy to Clipboard Toggle word wrap
    1
    指定 PCCS URL,例如 https://localhost:8081/sgx/certification/v4/
  2. 运行以下命令来创建 TDX 配置映射:

    $ oc apply -f tdx-config.yaml
    Copy to Clipboard Toggle word wrap

7.13.4. 使用客户端自定义密钥创建 secret

您可以为 Trustee 客户端创建一个包含一个或多个自定义密钥的 secret。

在本例中,kbsres1 机密有两个条目(key 1、key2),客户端会检索它们。您可以使用相同的格式根据您的要求添加额外的 secret。

先决条件

  • 您已创建了一个或多个自定义密钥。

流程

  • 根据以下示例,为自定义密钥创建 secret:

    $ oc apply secret generic kbsres1 \
      --from-literal key1=<custom_key1> \ 
    1
    
      --from-literal key2=<custom_key2> \
      -n trustee-operator-system
    Copy to Clipboard Toggle word wrap
    1
    指定自定义密钥。

    kbsres1 secret 在 KbsConfig 自定义资源的 spec.kbsSecretResources 键中指定。

7.13.5. 为容器镜像签名验证创建 secret

如果使用容器镜像签名验证,您必须创建一个包含公共容器镜像签名密钥的 secret。

Confidential compute attestation Operator 使用 secret 来验证签名,确保环境中仅部署可信和经过身份验证的容器镜像。

您可以使用 Red Hat Trusted Artifact Signer 或其他工具为容器镜像签名。

流程

  1. 运行以下命令,为容器镜像签名验证创建 secret:

    $ oc apply secret generic <type> \ 
    1
    
      --from-file=<tag>=./<public_key_file> \ 
    2
    
      -n trustee-operator-system
    Copy to Clipboard Toggle word wrap
    1
    指定 KBS secret 类型,例如 img-sig
    2
    指定 secret 标签,如 pub-key,以及公共容器镜像签名密钥。
  2. 记录 &lt ;type&gt; 值。在创建 KbsConfig 自定义资源时,您必须将这个值添加到 spec.kbsSecretResources 键中。

7.13.6. 创建容器镜像签名验证策略

您可以创建容器镜像签名验证策略,因为始终启用签名验证。如果缺少此策略,则 pod 不会启动。

如果您不使用容器镜像签名验证,您可以在不签名验证的情况下创建策略。

如需更多信息,请参阅 containers-policy.json 5

流程

  1. 根据以下示例创建 security-policy-config.json 文件:

    • 没有签名验证:

      {
        "default": [
        {
          "type": "insecureAcceptAnything"
        }],
        "transports": {}
      }
      Copy to Clipboard Toggle word wrap
    • 使用签名验证:

      {
        "default": [
            {
            "type": "insecureAcceptAnything"
            }
        ],
        "transports": {
            "<transport>": { 
      1
      
                "<registry>/<image>": 
      2
      
                [
                    {
                        "type": "sigstoreSigned",
                        "keyPath": "kbs:///default/<type>/<tag>" 
      3
      
                    }
                ]
            }
        }
      }
      Copy to Clipboard Toggle word wrap
      1
      指定 传输的 镜像存储库,例如 "docker":。如需更多信息,请参阅 containers-transports 5
      2
      指定容器 registry 和镜像,例如 "quay.io/my-image"。
      3
      指定您创建的容器镜像签名验证 secret 的类型和标签,例如 img-sig/pub-key
  2. 运行以下命令来创建安全策略:

    $ oc apply secret generic security-policy \
      --from-file=osc=./<security-policy-config.json> \
      -n trustee-operator-system
    Copy to Clipboard Toggle word wrap

    不要更改机密类型 security-policy 或 key, osc

    security-policy secret 在 KbsConfig 自定义资源的 spec.kbsSecretResources 键中指定。

7.13.7. 创建资源访问策略

您可以为 Trustee 策略引擎配置资源访问策略。此策略决定信任哪个资源可以访问。

注意

Trustee 策略引擎与 Attestation Service 策略引擎不同,后者决定了 TEE 证据的有效性。

流程

  1. 创建 resourcepolicy-configmap.yaml 清单文件:

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: resource-policy
      namespace: trustee-operator-system
    data:
      policy.rego:
        package policy
        default allow = true
        allow {
          input["tee"] != "sample"
        }
    Copy to Clipboard Toggle word wrap
    policy.rego
    资源策略 policy.rego 的名称必须与 Trustee 配置映射中定义的资源策略匹配。
    软件包策略
    资源策略遵循 Open Policy Agent 规格。
  2. 运行以下命令来创建资源策略配置映射:

    $ oc apply -f resourcepolicy-configmap.yaml
    Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat