AgentCardVerifier¶
The AgentCardVerifier class provides methods for verifying signed A2A Agent Cards using Sigstore.
Overview¶
from sigstore_a2a import AgentCardVerifier
verifier = AgentCardVerifier(
oidc_issuer="https://token.actions.githubusercontent.com"
)
result = verifier.verify_file("signed-card.json")
if result.valid:
print("Signature verified!")
API Reference¶
AgentCardVerifier
¶
AgentCardVerifier(
identity: str | None = None,
oidc_issuer: str | None = None,
staging: bool = False,
trust_config: Path | None = None,
)
Verifies signed A2A Agent Cards using Sigstore.
Initialize the Agent Card verifier.
| PARAMETER | DESCRIPTION |
|---|---|
identity
|
The expected identity that has signed the model
TYPE:
|
oidc_issuer
|
The expected OpenID Connect issuer that provided the certificate used for the signature
TYPE:
|
staging
|
Use Sigstore staging environment
TYPE:
|
trust_config
|
A path to a custom trust configuration
TYPE:
|
Source code in sigstore_a2a/verifier.py
verify_signed_card
¶
verify_signed_card(
signed_card: (
SignedAgentCard | dict[str, Any] | str | Path
),
constraints: IdentityConstraints | None = None,
) -> VerificationResult
Verify a signed Agent Card.
| PARAMETER | DESCRIPTION |
|---|---|
signed_card
|
Signed agent card to verify
TYPE:
|
constraints
|
Optional identity constraints
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
VerificationResult
|
Verification result |
Source code in sigstore_a2a/verifier.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | |
verify_file
¶
verify_file(
file_path: str | Path,
constraints: IdentityConstraints | None = None,
) -> VerificationResult
Verify a signed Agent Card file.
| PARAMETER | DESCRIPTION |
|---|---|
file_path
|
Path to signed Agent Card file
TYPE:
|
constraints
|
Optional identity constraints
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
VerificationResult
|
Verification result |
Source code in sigstore_a2a/verifier.py
IdentityConstraints
¶
IdentityConstraints(
repository: str | None = None,
workflow: str | None = None,
identity: str | None = None,
identity_provider: str | None = None,
)
Identity constraints for signature verification.
Initialize identity constraints.
| PARAMETER | DESCRIPTION |
|---|---|
repository
|
Required repository (e.g., "owner/repo")
TYPE:
|
workflow
|
Required workflow name or path
TYPE:
|
identity
|
Required identity
TYPE:
|
identity_provider
|
Required OIDC issuer
TYPE:
|
Source code in sigstore_a2a/verifier.py
VerificationResult
¶
VerificationResult(
valid: bool,
agent_card: AgentCard | None = None,
certificate: Certificate | None = None,
identity: dict[str, Any] | None = None,
errors: list[str] | None = None,
)
Result of Agent Card verification.
Initialize verification result.
| PARAMETER | DESCRIPTION |
|---|---|
valid
|
Whether verification succeeded
TYPE:
|
agent_card
|
Verified agent card (if valid)
TYPE:
|
certificate
|
Signing certificate
TYPE:
|
identity
|
Extracted identity information
TYPE:
|
errors
|
List of verification errors
TYPE:
|
Source code in sigstore_a2a/verifier.py
Usage Examples¶
Basic Verification¶
from sigstore_a2a import AgentCardVerifier
verifier = AgentCardVerifier(
oidc_issuer="https://token.actions.githubusercontent.com"
)
result = verifier.verify_file("signed-card.json")
if result.valid:
print("✓ Signature verified!")
print(f" Agent: {result.agent_card.name}")
print(f" Signed by: {result.identity.get('subject')}")
else:
print("✗ Verification failed:")
for error in result.errors:
print(f" - {error}")
Verification with Constraints¶
from sigstore_a2a import AgentCardVerifier
from sigstore_a2a.verifier import IdentityConstraints
verifier = AgentCardVerifier(
oidc_issuer="https://token.actions.githubusercontent.com"
)
# Define constraints
constraints = IdentityConstraints(
repository="sigstore/sigstore-a2a",
workflow="Release"
)
result = verifier.verify_file("signed-card.json", constraints)
Verifying with Google Identity¶
verifier = AgentCardVerifier(
identity="user@example.com",
oidc_issuer="https://accounts.google.com"
)
result = verifier.verify_file("signed-card.json")
Using Staging Environment¶
verifier = AgentCardVerifier(
oidc_issuer="https://token.actions.githubusercontent.com",
staging=True
)
Using Custom Trust Configuration¶
from pathlib import Path
verifier = AgentCardVerifier(
oidc_issuer="https://my-idp.example.com",
trust_config=Path("/path/to/trust-config.json")
)
Extracting Identity Information¶
result = verifier.verify_file("signed-card.json")
if result.valid:
identity = result.identity
print(f"Issuer: {identity.get('issuer')}")
print(f"Subject: {identity.get('subject')}")
print(f"Repository: {identity.get('github_workflow_repository')}")
print(f"Workflow: {identity.get('github_workflow_name')}")
print(f"Commit SHA: {identity.get('github_workflow_sha')}")
Identity Providers¶
Common OIDC issuers for verification:
| Provider | Issuer URL |
|---|---|
| GitHub Actions | https://token.actions.githubusercontent.com |
https://accounts.google.com |
|
| Microsoft | https://login.microsoftonline.com/{tenant}/v2.0 |
| GitLab | https://gitlab.com |