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
| Step | What it decides | Codes |
|---|---|---|
| 1 | prepares verification and reads status from cache | R12 |
| 2 | takes the allowed algorithm and the key inside x5c | R01, R02, R03 |
| 3 | canonicalizes with JCS and validates the JWS | R04 |
| 4 | validates the x5c chain and leaf conformance | R05, R06 |
| 5 | requires SAN URI equal to the origin and a proven origin | R07, R08 |
| 6 | requires validity and a bound inclusion proof | R09, R10, R11 |
| 7 | queries the status list by its three indexes | R12 |
| 8 | validates the mandate and its issuer when the action asks for it | R13, R14 |
| 9 | returns agent_id, operador, nivel and reasons | none |
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
| Code | What happened | What to do |
|---|---|---|
R01 | algorithm not allowed | sign with EdDSA; ES256 is not issued in v1 |
R02 | the key is not in x5c or the chain cannot be read | include the issued chain in the signature |
R03 | kid is not the SPKI fingerprint of x5c[0] | recompute the kid when signing |
R04 | the JWS does not verify over the canonical payload | sign JCS(card without signatures) |
R05 | the chain does not reach a trust package root | use the issued chain and refresh the package |
R06 | the leaf is not conformant: CA, EKU, keyUsage or SAN | request a class leaf, not a CA |
R07 | the SAN URI does not match the origin URL | publish the card at the exact SAN URL |
R08 | the origin is not proven | serve the card over HTTPS at that origin |
R09 | the card is not valid at this instant | renew with ARI before it expires |
R10 | the inclusion proof is missing or the checkpoint regressed | request the proof from the log |
R11 | the proof does not bind the leaf to the card | sign again with the correct proof |
R12 | status suspended, expired or publisher down | check the list; the verifier fails closed |
R13 | invalid mandate, reused nonce or action outside limits | request a fresh presentation |
R14 | mandate issuer not admitted or key mismatch | use an issuer from the closed list |
R15 | foreign 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_lineais 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.