Agent 自助注册
通过 Agent Trust 注册 Agent、验证身份,并在接入模式要求时获得审批。
Agent Trust 支持 Agent 自助接入,并通过基于任务的 A2A 协议申请 PKI 证书。本教程介绍发现、注册、CSR 申请、证书提取和 mTLS 认证。
1. 发现 API#
每个部署都会发布描述能力和认证方案的 agent card:
curl http://<gateway-host>/.well-known/agent-card.jsonCard 公布 A2A endpoints、接受的认证方式(bearer 和/或 mTLS)及 skills。创建客户端前先读取,它是部署的权威信息。
2. 注册#
使用唯一 agentId 和身份凭证(公钥)注册:
POST /a2a/v1/register
{
"agentId": "my-agent@corp.example",
"displayName": "My Agent",
"publicKeyPem": "-----BEGIN PUBLIC KEY----- …",
"usage": "Document Q&A assistant for legal",
"dataClassification": "Internal",
"tags": ["legal", "qa"]
}身份绑定首个已认证调用方(或来源 IP),该调用方拥有 agentId。每个 Agent 应使用唯一 ID。同一 IP 下没有 agentId 的 Agent 会合并;相同 agentId 从两个 host 注册会被拒绝。管理员不能修改身份凭证;通过同一发送方重新注册进行轮换。
3. 使用 CSR 申请证书#
在本地生成密钥对和 CSR。私钥永不离开 Agent:
openssl req -new -newkey rsa:2048 -nodes -keyout agent.key -out agent.csr -subj "/CN=my-agent@corp.example"将 CSR 作为 A2A task 发送:
POST /a2a/v1/tasks/send
{
"contextId": "enrollment-001",
"message": {
"role": "user",
"parts": [{
"kind": "file",
"mimeType": "application/x-pem-file",
"name": "agent.csr",
"bytes": "<base64 of agent.csr>"
}]
}
}4. 轮询任务#
证书服务异步处理请求。轮询直到任务完成:
GET /a2a/v1/tasks/{taskId}预期状态为 completed,结果 artifact 包含签发的证书链。
5. 提取证书#
下载 artifact。证书链包括 leaf 和中间证书,不含 root。Leaf SAN 必须覆盖连接的 gateway host:
curl -o cert.pem http://<gateway-host>/a2a/v1/tasks/{taskId}/artifacts/{artifactId}6. 使用 mTLS 认证#
配置客户端提交证书和私钥。连接 SAN 中列出的 host 并验证 CA 链。不要在 Agent 间共享私钥。
保护私钥
私钥保留在 Agent 本地。若丢失或泄露,请按流程撤销,并使用新凭据重新注册 Agent。