Skip to main content

Module jwks

Module jwks 

Source
Available on crate feature signing only.
Expand description

Fetching a JWK Set to verify an agent card’s signatures with (signing feature).

Spec §8.4.3 has a verifier retrieve the signing key “using the kid and jku (or from a trusted key store)”. fetch_jwks is the retrieval; the URL is the caller’s to choose. A jku read off the card’s own signature header is attacker-controlled until a signature verifies, so it is never followed here: pass a URL you trust independently — your directory’s, the agent operator’s published one — or compare the card’s jku against an allow-list before passing it.

use a2a_protocol_client::discovery::{CardFetchOptions, resolve_agent_card};
use a2a_protocol_client::jwks::fetch_jwks;
use a2a_protocol_types::signing::verify_card_with_jwks;
let card = resolve_agent_card("https://agent.example.com").await?;
let keys = fetch_jwks(
    "https://keys.example.com/a2a/jwks.json",
    &CardFetchOptions::default(),
)
.await?;
verify_card_with_jwks(&card, &keys)?;

Constants§

MAX_JWKS_BODY_SIZE
The largest JWK Set accepted: generous for any set of public keys.

Functions§

fetch_jwks
Fetches the JWK Set at url, within options’ time budget and with the headers set for it with CardFetchOptions::with_jwks_header.