Skip to content
CRDCA.CA for agents
ESEN

Verify a card without calling CRDCA

The middleware runs the verifier's nine steps with the trust package and the status list in cache, and rejects with a code from R01 to R15.

Whoever receives a card does not ask CRDCA whether it is valid. It runs the verifier with the trust package and the status list already in cache, decides in a single call and returns a code when it rejects. The issuer is not on the call path.

The nine steps

StepWhat it decidesCodes
1prepares verification and reads status from cacheR12
2takes the allowed algorithm and the key inside x5cR01, R02, R03
3canonicalizes with JCS and validates the JWSR04
4validates the x5c chain and leaf conformanceR05, R06
5requires SAN URI equal to the origin and a proven originR07, R08
6requires validity and a bound inclusion proofR09, R10, R11
7queries the status list by its three indexesR12
8validates the mandate and its issuer when the action asks for itR13, R14
9returns agent_id, operador, nivel and reasonsnone

Step 9 only returns the result. The other eight decide. In bloquear mode the first rejection stops verification; in advertir mode the call passes but the reason is recorded. The aliases estricto and tolerante are accepted.

In Python

from crdca.middleware import Contexto, Tarjeta, verificar

resultado = verificar(
    Tarjeta(
        jws=jws_compacto,
        url_origen=card_url,
        cuerpo=tarjeta,
        origen_probado=True,
        prueba_inclusion=prueba,
        mandato=mandato,
    ),
    Contexto(
        paquete=paquete,
        estado=cache_de_estado,
        log=log,
        mandato=verificador_de_mandato,
        modo="bloquear",
        accion_pide_mandato=False,
    ),
)
print(resultado.aceptada, resultado.codigos, resultado.nivel)

The middleware reads no files and makes no network calls: it receives six collaborators through Protocol —trust package, status list, log, mandate verifier, signature verifier and clock. You build them with the real components or with in-memory doubles. If the status publisher does not respond, step 1 rejects with R12; there is no fallback copy.

In Go

The middleware package serves the gateway filter. The authz command exposes it over HTTP for Envoy:

cd src/go
go run ./cmd/authz -addr 127.0.0.1:8085 -modo bloquear

A call without a card is rejected at step 2:

curl -i http://127.0.0.1:8085/
# HTTP/1.1 403 Forbidden
# x-crdca-codigo: R02_KEY_SOURCE_NOT_X5C
# x-crdca-paso: 2
# x-crdca-modo: bloquear

The card travels in individual headers (x-crdca-alg, x-crdca-kid, x-crdca-jws, x-crdca-x5c) or in a single x-crdca-card, with the JWS and the chain separated by . or in JSON. When it allows the call, it responds 200 and adds x-crdca-agent, x-crdca-operador, x-crdca-nivel and x-crdca-paso.

The Envoy filter

Envoy calls the verifier as an HTTP ext_authz filter. The real configuration uses path_prefix: /check, server_uri: http://authz:8080, timeout: 2s and failure_mode_allow: false: if the verifier does not answer, the request does not pass. Only allowed headers reach the portal; the client receives x-crdca-codigo, x-crdca-paso and x-crdca-modo.

In TypeScript

The TypeScript verification piece is the A2A plugin @nexgensys/crdca-plugin-a2a. It verifies A2A message signatures and the mandate with local keys; it downloads no keys and does not call CRDCA. The card's nine-step algorithm is implemented in Python and Go; in TypeScript, card verification is delegated to one of those middleware.

import { readFileSync } from 'node:fs';
import { leerMandato, verificarMensaje } from '@nexgensys/crdca-plugin-a2a';

const mensaje = JSON.parse(readFileSync('mensaje.json', 'utf8'));
const { mandato, superficie } = leerMandato({
  cabeceras: { 'CRDCA-Mandate': process.env.CRDCA_MANDATE ?? '' },
});
const decision = verificarMensaje(mensaje, {
  claves: [readFileSync('cadena-clase.pem', 'utf8')],
});
console.log(decision.aceptado, decision.motivo, decision.verificadas);
console.log(mandato, superficie);

The plugin accepts one form of signatures[]: A2A v1.0, with protected and signature. Any other form is rejected with firma_no_reconocida. Without a local key that resolves the kid, there is no acceptance even if the message carries x5c.

What each rejection means

CodeWhat happenedWhat to do
R01algorithm not allowedsign with EdDSA; ES256 is not issued in v1
R02the key is not in x5c or the chain cannot be readinclude the issued chain in the signature
R03kid is not the SPKI fingerprint of x5c[0]recompute the kid when signing
R04the JWS does not verify over the canonical payloadsign JCS(card without signatures)
R05the chain does not reach a trust package rootuse the issued chain and refresh the package
R06the leaf is not conformant: CA, EKU, keyUsage or SANrequest a class leaf, not a CA
R07the SAN URI does not match the origin URLpublish the card at the exact SAN URL
R08the origin is not provenserve the card over HTTPS at that origin
R09the card is not valid at this instantrenew with ARI before it expires
R10the inclusion proof is missing or the checkpoint regressedrequest the proof from the log
R11the proof does not bind the leaf to the cardsign again with the correct proof
R12status suspended, expired or publisher downcheck the list; the verifier fails closed
R13invalid mandate, reused nonce or action outside limitsrequest a fresh presentation
R14mandate issuer not admitted or key mismatchuse an issuer from the closed list
R15foreign log without a valid anchor (v2)provide the anchor or use the CRDCA log

Why no call to CRDCA is needed

  • The trust package carries roots and revocations, signed and with its validity window.
  • The status list is signed and read from a cache with a 240 s window over a 300 s cadence.
  • The log checkpoint is monotonic and the inclusion proof is verified against it.
  • The verifier does not query the issuer: llamadas_en_linea is zero. If status is not fresh, it

rejects; it does not accept an expired copy or invent an answer.

Next step

  • The human mandate: the header that activates step 8.
  • The CLI: how to produce the card and the proof this verifier consumes.