Skip to content
Wallet and Entity Collection draft updates
Documentation menu

4.4. Resolve protocol keys from trusted metadata

Feature guides / 4. Metadata · Example context

LIGO Wiki has validated Umeå University OP's federation chain. It now needs Umeå University OP's protocol keys to verify OIDC messages. The EC's federation JWKS authenticated the federation evidence; protocol metadata tells LIGO Wiki where to obtain the protocol keys.

How to use it

Use the protocol role operation that needs the keys. Wallet verification resolves keys from authenticated effective metadata before calling the host's format verifier. OIDC registration resolves the peer's keys as part of its registration workflow. Keep the role's protocol signing purposes separate from the federation signing purpose configured on its host.

import type { CredentialVerifierRole } from "@oidfed/wallet";
import type { CredentialVerificationOptions } from "@oidfed/wallet";

export function verifyMemberCredential(
  verifier: CredentialVerifierRole, credential: unknown,
  verifyCredential: CredentialVerificationOptions["verifyCredential"],
) {
  return verifier.verifyCredential(credential, "https://licensing-authority.example", {
    verifyCredential, // Receives trusted issuer metadata and resolved protocol keys.
  });
}

For a custom protocol integration with no matching role operation, core's resolveEntityKeys() exposes the same key-source resolution. Supply effective metadata and federation keys from already validated evidence, plus expectedIssuer and expectedOwner. The key API describes the standalone contract.

What your application owns

Validate the protocol signature and claims with the resolved keys. Fallback is off by default. If enabled, it applies only to classified availability failures, such as transport failures and selected HTTP statuses. Invalid signatures, malformed responses, and cancellation do not justify accepting another source. Mixed signing and encryption JWK sets need the prescribed use information. Coordinate protocol-key rollover with your protocol engine.

An empty keys array is valid protocol metadata. It cannot verify a signature, and a valid empty signed set does not authorize fallback to unsigned keys. Federation signing sets still need at least one key.

Keep the two key lifecycles visible

Umeå University OP's federation keys authenticate Entity Statements. Its OP keys authenticate protocol artifacts such as ID Tokens or signed Request Objects according to the protocol. Track those inventories separately even when a deployment uses the same key-management service.

When metadata points to a remote JWKS, use the configured transport controls and the library's verified resolution path. Treat malformed signed key data as a validation failure, not a reason to accept unrelated keys. An empty protocol JWKS can be a valid data shape; whether it provides a usable key for a particular operation is a separate check.

Federation and protocol signing keys

OpenID Federation §3.1.1 says Federation Entity Keys SHOULD NOT be used for other protocols. oidfed supports separate federation and protocol signing purposes so applications can maintain that separation. Federation keys sign federation artifacts and federation endpoint client assertions; protocol keys sign OIDC/OAuth Request Objects and protocol client assertions.

The application manages protocol-key rotation and publishes the matching public keys in role metadata. Configure signing.requestObject and signing.clientAssertion on RP roles. Managed roles derive their inline JWKS from those keyring purposes. Configure explicit aliases when operations share a key.

Protocol key sets, signed sources, and fallback

JWKSchema and JWKSetSchema provide structural parsing. Received sets retain unknown kty values; verification skips unsupported key types. Mandatory key-set rules still apply, and protocol kid omission depends on the original published key count. An incomplete, unselected key can coexist with a valid signing key, consistent with RFC 7517 §5. Federation publication checks apply to the top-level jwks. Composed hosts and statement builders also require supported public key types in inline protocol metadata. Generic JWT signing remains a lower-level operation.

MetadataJWKSetSchema parses public protocol keys under Federation §5.2.1. A key can omit kid, and different keys can share an identifier where the protocol permits it (RFC 7517 §4.5). resolveEntityKeys() applies this schema to inline jwks and HTTPS jwks_uri responses; signed JWK Set payloads use the same key schema. The signed envelope uses federation keys and requires its own header kid. Protocol sets may contain keys: [], as permitted by RFC 7517 §5. An empty signed set remains authoritative and does not trigger fallback. Signature verification still requires a usable key; Federation signing sets remain non-empty.

resolveEntityKeys(), fetchSignedJwkSet(), and verifySignedJwkSet() require expectedIssuer and expectedOwner. Supply both from authenticated entity context. §5.2.1 recommends that issuer and owner match; explicitly expected distinct identities are accepted. Historical-key fetch and verification helpers require expectedIssuer.

Signed JWK Set retrieval requires HTTP 200. By default, resolveEntityKeys() returns the first failure. Set allowFallback: true to try another advertised key source after a transport error, timeout, HTTP 404/410, or HTTP 500/502/503/504. It stops on cancellation, invalid signatures or identities, malformed keys, URL-policy rejection, an unexpected status or content type, oversized bodies, or other response-body failures. Those failures, and any unclassified failure, never trigger a fetch from a lower-priority source.

verifyProtocolJwt(jwt, jwks, options) verifies protocol JWTs against authenticated metadata keys. Set expectedTyp to the protocol's required type. The default keyIdPolicy: "required" requires a header kid; "single-key" permits omission when the supplied set contains exactly one key, following OIDC Core §10.1. A supplied identifier must match. Candidate selection checks the signing algorithm, key type, curve and usage before signature verification. The helper checks JWT time claims using clock and clockSkewSeconds; callers bind the keys to the expected entity and validate protocol claims, including issuer and audience. verifyEntityStatement() retains the federation header requirements.

Next: 5. Federation policy

View source on GitHub