# 信任模型 ## 信任域 ### 什么是信任域? 信任域(Trust Domain)代表管理控制和身份颁发的边界。它由一个类 DNS 的名称标识(例如 `example.org`),是 SPIRE 颁发的所有 SPIFFE ID 的根。 ### 信任域配置 信任域在 Server 和 Agent 中都需要配置: **Server 配置:** ```hcl server { trust_domain = "example.org" } ``` **Agent 配置:** ```hcl agent { trust_domain = "example.org" } ``` ## 信任包(Trust Bundle) ### 定义 信任包包含用于验证 SVID 的根 CA 证书和 JWT 签名密钥。 ### 信任包类型 1. **本地信任包**: 本信任域的 CA 证书 2. **联邦信任包**: 其他信任域的 CA 证书 ### 信任包管理 ```{mermaid} flowchart LR subgraph "Server" BM[包管理器] DS[数据存储] end subgraph "外部系统" S3[AWS S3] GCS[GCP Storage] FD[联邦域] end BM --> DS BM --> S3 BM --> GCS BM <--> FD ``` ## 证明机制 ### 节点证明 节点证明(Node Attestation)在 Agent 首次连接 Server 时建立 Agent 的身份。 **支持的证明方法:** | 方法 | 描述 | |------|------| | `aws_iid` | AWS 实例身份文档 | | `azure_msi` | Azure 托管服务身份 | | `gcp_iit` | GCP 实例身份令牌 | | `k8s_psat` | Kubernetes 投影服务账户令牌 | | `join_token` | 一次性加入令牌 | ### 工作负载证明 工作负载证明(Workload Attestation)确定工作负载应该接收哪些 SPIFFE ID。 **证明流程:** 1. 工作负载连接到 Workload API Unix 套接字 2. Agent 通过 `peertracker` 确定工作负载的 PID 3. WorkloadAttestor 插件生成选择器 4. Agent 将选择器与缓存的注册条目匹配 5. Agent 返回相应的 X.509-SVID ## 联邦 ### 概述 联邦允许不同信任域中的工作负载相互认证。 ### 配置示例 ```hcl server { federation { bundle_endpoint { address = "0.0.0.0" port = 8443 } federates_with "partner.org" { bundle_endpoint_url = "https://spire.partner.org:8443" bundle_endpoint_profile "https_spiffe" { endpoint_spiffe_id = "spiffe://partner.org/spire/server" } } } } ``` ## 安全考虑 :::{admonition} 安全提示 :class: warning 1. 保护信任域名称,避免泄露 2. 定期轮换 CA 密钥 3. 限制注册条目的创建权限 4. 监控异常的身份颁发活动 ::: ## 下一步 了解 {doc}`/1.overview/svid-types` 以理解 SPIRE 支持的身份凭证类型。