Online Revocation Plugin — API Reference
@trexolab/certeno-plugin-revocation
Overview
The revocation plugin adds online CRL (Certificate Revocation List) and OCSP (Online Certificate Status Protocol) checking to the Certeno verification engine. For every certificate in a signer's chain that the document itself leaves unanswered, it downloads the CA's CRL or OCSP response.
The plugin transports; the engine judges. A downloaded response is handed back to the WASM engine as raw bytes. The engine verifies who signed it, which certificate it is about and which period it covers, and only then lets it settle that certificate's status. Nothing in this package interprets a CRL or an OCSP response, so nothing in it — and no server it is proxied through — can make a certificate look better than the CA's own signed data allows.
The plugin operates in two modes:
- Proxy mode (browser) — sends revocation requests to your server handler, which fetches CRL/OCSP data on behalf of the browser. Required because browsers cannot directly reach most CRL/OCSP endpoints due to CORS and mixed-content restrictions.
- Direct mode (Node.js) — fetches CRL/OCSP endpoints directly from the running process. No server needed.
Mode detection is automatic: if endpoint is provided, the plugin uses proxy mode; if omitted, it uses direct mode.
The package exposes four import paths, each targeting a different runtime context.
Import Paths
| Path | Exports | When to use |
|---|---|---|
@trexolab/certeno-plugin-revocation | revocationPlugin, types | Browser or Node.js client — creates the plugin instance |
@trexolab/certeno-plugin-revocation/handler | handleRevocation | Server handler using Web Standard Request/Response (Next.js, Hono, Bun, Deno, Cloudflare Workers) |
@trexolab/certeno-plugin-revocation/handler/express | expressHandler | Server handler for Express |
@trexolab/certeno-plugin-revocation/handler/core | processRevocation | Raw data-in/data-out function for custom frameworks, testing, or Fastify |
revocationPlugin(options?)
Creates a revocation checking plugin that conforms to the CertenoPlugin interface.
import { revocationPlugin } from '@trexolab/certeno-plugin-revocation'
function revocationPlugin(options?: RevocationPluginOptions): CertenoPluginParameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
options | RevocationPluginOptions | No | Plugin configuration. See RevocationPluginOptions for all fields. |
Returns: CertenoPlugin — a plugin object with name: 'revocation' and a revocation.fetch method.
Mode detection:
endpointpresent in options --> proxy mode (browser-safe)endpointabsent --> direct mode (Node.js)
The returned plugin object has this shape:
{
name: 'revocation',
revocation: {
fetch: (request: RevocationFetchRequest) => Promise<Uint8Array | null>,
}
}fetch resolves to the response body exactly as received, or null when nothing usable came back. A request for a kind that is switched off (crl: false, ocsp: false) resolves to null without touching the network.
type RevocationFetchRequest = (
| { kind: 'crl'; url: string } // GET url
| { kind: 'ocsp'; url: string; body: Uint8Array } // POST body as application/ocsp-request
) & {
subject?: string // the certificate being asked about — for logging only
}The OCSP request body comes from the engine (CertificateInfo.ocspRequest), which builds it from the issuer's name and key. The plugin never constructs one.
Proxy Mode (Browser)
When endpoint is provided, every download is made by your server: the plugin sends it a JSON POST describing the download and gets the bytes back.
const plugin = revocationPlugin({ endpoint: '/api/revocation' })Internal flow:
- The core engine calls
fetch(request)for a certificate the document left unanswered. - The plugin builds a
RevocationRequestJSON payload. An OCSP request body is base64, since JSON has no bytes:json{ "kind": "ocsp", "url": "http://ocsp.example.com", "body": "MEUwQzBBMD8wPTAJ…", "subject": "CN=Jane Doe, O=Example" }json{ "kind": "crl", "url": "http://crl.example.com/ca.crl", "subject": "CN=Example Issuing CA" } - The plugin sends
POST <endpoint>withContent-Type: application/jsonand the JSON body. - Custom headers (static or dynamic) are merged into the request if configured.
- An
AbortControllerenforces the configuredtimeout(default: 10 seconds). - The server handler makes the download and answers
200with the response body asapplication/octet-stream. - A
403(the handler's URL filter refused the address) or502(the download failed) means this source has nothing; the plugin resolves tonulland the engine tries the next source. Any other failure — network error, timeout, an unexpected status — invokesonError(if configured) and also resolves tonull.
Request format:
type RevocationRequest = (
| { kind: 'crl'; url: string }
| { kind: 'ocsp'; url: string; body: string } // body: base64 of the DER OCSP request
) & {
subject?: string
}Response format:
| HTTP Status | Body | Meaning |
|---|---|---|
200 | The CRL or OCSP response, application/octet-stream | Downloaded. Not yet judged — that happens in the engine. |
400 | { "error": "invalid" } | Not a RevocationRequest |
403 | { "error": "refused" } | The URL filter rejected the address |
502 | { "error": "failed" } | The CA did not return a usable body |
Timeout handling:
The plugin creates an AbortController and aborts the fetch after timeout milliseconds (default: 10000). On abort, the onError callback fires and fetch resolves to null.
Custom headers:
Static headers:
revocationPlugin({
endpoint: '/api/revocation',
headers: { 'Authorization': 'Bearer my-token' },
})Dynamic headers (evaluated on each request):
revocationPlugin({
endpoint: '/api/revocation',
headers: () => ({ 'Authorization': `Bearer ${getToken()}` }),
})Headers are merged into the request after the default Content-Type: application/json header.
Error handling and the onError callback:
When a request fails, the plugin:
- Catches the error.
- Wraps it as an
Errorif it is not already one. - Calls
onError(error, { type, url })if the callback is configured. - Resolves to
null.
The verification still completes — the certificate in question simply stays unanswered.
revocationPlugin({
endpoint: '/api/revocation',
onError: (err, ctx) => {
console.warn(`Revocation ${ctx.type} failed for ${ctx.url}:`, err.message)
// ctx.type is 'crl' or 'ocsp'
// ctx.url is the endpoint URL (proxy mode) or the CA's URL (direct mode)
},
})Direct Mode (Node.js)
When endpoint is omitted, the plugin makes the downloads itself using fetch().
const plugin = revocationPlugin()
// or with options:
const plugin = revocationPlugin({ timeout: 15000, maxCrlSize: 5 * 1024 * 1024 })Internal flow:
- For CRL:
GETthe URL, following redirects. - For OCSP:
POSTthe engine-built request to the responder withContent-Type: application/ocsp-request. - A non-2xx status, an empty body, or a body larger than
maxCrlSize(default: 10 MB, checked againstContent-Lengthand the actual size) resolves tonull. - No server handler is needed.
handleRevocation(options?)
Creates a Web Standard request handler for revocation checking. Compatible with any framework that uses the Web Standard Request/Response API.
import { handleRevocation } from '@trexolab/certeno-plugin-revocation/handler'
function handleRevocation(options?: HandlerOptions): (req: Request) => Promise<Response>Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
options | HandlerOptions | No | Server handler configuration. See HandlerOptions. |
Returns: An async function (req: Request) => Promise<Response>.
Request validation:
The handler parses the request body as JSON and checks that it is a RevocationRequest. If not, it returns a 400 response.
SSRF protection:
Before fetching, the handler applies the urlFilter function (or the default filter) to the URL. A URL that does not pass is not fetched, and the handler answers 403.
Response format:
| HTTP Status | Body | When |
|---|---|---|
200 | The CRL or OCSP response as received, application/octet-stream | The download succeeded |
400 | { "error": "invalid" } | The body is not a RevocationRequest |
403 | { "error": "refused" } | The URL filter rejected the address |
502 | { "error": "failed" } | Non-2xx from the CA, timeout, empty body, or larger than maxCrlSize |
The handler does not read what it relays. If you wrap it — to add CORS headers or logging — pass the body through as bytes (await res.arrayBuffer()), never as text, and do not log it: a CA-wide CRL can run to megabytes.
Next.js App Router
// app/api/revocation/route.ts
import { handleRevocation } from '@trexolab/certeno-plugin-revocation/handler'
export const POST = handleRevocation()Hono
import { Hono } from 'hono'
import { handleRevocation } from '@trexolab/certeno-plugin-revocation/handler'
const app = new Hono()
const handler = handleRevocation()
app.post('/api/revocation', (c) => handler(c.req.raw))
export default appBun
import { handleRevocation } from '@trexolab/certeno-plugin-revocation/handler'
const handler = handleRevocation()
Bun.serve({
port: 3000,
async fetch(req) {
const url = new URL(req.url)
if (url.pathname === '/api/revocation' && req.method === 'POST') {
return handler(req)
}
return new Response('Not found', { status: 404 })
},
})Deno
import { handleRevocation } from '@trexolab/certeno-plugin-revocation/handler'
const handler = handleRevocation()
Deno.serve({ port: 3000 }, async (req) => {
const url = new URL(req.url)
if (url.pathname === '/api/revocation' && req.method === 'POST') {
return handler(req)
}
return new Response('Not found', { status: 404 })
})expressHandler(options?)
Creates an Express-compatible request handler for revocation checking.
import { expressHandler } from '@trexolab/certeno-plugin-revocation/handler/express'
function expressHandler(options?: HandlerOptions): (req: any, res: any) => Promise<void>Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
options | HandlerOptions | No | Server handler configuration. See HandlerOptions. |
Returns: An Express middleware function (req, res) => Promise<void>.
Prerequisite: The express.json() middleware must be applied before this handler so that req.body is parsed. Without it, req.body will be undefined and the handler will return a 400 error.
The statuses and bodies are the same as handleRevocation. A success is written with res.end(bytes).
Example
import express from 'express'
import { expressHandler } from '@trexolab/certeno-plugin-revocation/handler/express'
const app = express()
app.use(express.json())
app.post('/api/revocation', expressHandler())
app.listen(3000, () => {
console.log('Revocation handler listening on port 3000')
})Example with options
import express from 'express'
import { expressHandler } from '@trexolab/certeno-plugin-revocation/handler/express'
const app = express()
app.use(express.json())
app.post('/api/revocation', expressHandler({
timeout: 15000,
maxCrlSize: 5 * 1024 * 1024,
urlFilter: (url) => {
const u = new URL(url)
return u.hostname.endsWith('.example-ca.com')
},
}))
app.listen(3000)processRevocation(payload, options?)
Framework-agnostic core function. Takes a plain RevocationRequest object, makes the download, and returns the outcome as plain data. No Request/Response objects involved.
import { processRevocation, STATUS_FOR } from '@trexolab/certeno-plugin-revocation/handler/core'
function processRevocation(
payload: RevocationRequest,
options?: HandlerOptions,
): Promise<RevocationResponse>
type RevocationResponse =
| { ok: true; body: Uint8Array }
| { ok: false; reason: 'invalid' | 'refused' | 'failed' }
const STATUS_FOR: { invalid: 400; refused: 403; failed: 502 }Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
payload | RevocationRequest | Yes | The download to make: kind, url, and for OCSP the base64 request body. |
options | HandlerOptions | No | Handler configuration. See HandlerOptions. |
Returns: Promise<RevocationResponse>. It does not throw.
Behavior:
- Checks the payload's shape. Anything else is
{ ok: false, reason: 'invalid' }. - Applies the
urlFiltertopayload.url. A rejected URL is{ ok: false, reason: 'refused' }; nothing is fetched. - For
kind: 'crl':GETs the URL. Forkind: 'ocsp': decodesbodyandPOSTs it asapplication/ocsp-request. - Returns the body as received, or
{ ok: false, reason: 'failed' }.
When to use:
- Custom frameworks that don't use Web Standard
Request/Responseor Express (e.g., Fastify, Koa, tRPC) - Testing and scripting
- Building your own handler wrapper
Fastify example
import Fastify from 'fastify'
import { processRevocation, STATUS_FOR } from '@trexolab/certeno-plugin-revocation/handler/core'
const fastify = Fastify()
fastify.post('/api/revocation', async (request, reply) => {
const result = await processRevocation(request.body as any, { timeout: 15000 })
if (!result.ok) {
return reply.code(STATUS_FOR[result.reason]).send({ error: result.reason })
}
reply.type('application/octet-stream').send(Buffer.from(result.body))
})
await fastify.listen({ port: 3000 })Testing example
import { processRevocation } from '@trexolab/certeno-plugin-revocation/handler/core'
const result = await processRevocation({
kind: 'crl',
url: 'http://crl.example.com/root.crl',
})
if (result.ok) console.log(`${result.body.length} bytes of CRL`)
else console.log(result.reason) // 'invalid', 'refused' or 'failed'Types
RevocationPluginOptions
Options passed to revocationPlugin(options?).
interface RevocationPluginOptions {
endpoint?: string
timeout?: number
crl?: boolean
ocsp?: boolean
maxCrlSize?: number
headers?: Record<string, string> | (() => Record<string, string>)
onError?: (error: Error, context: { type: 'crl' | 'ocsp'; url: string }) => void
}| Option | Type | Default | Description |
|---|---|---|---|
endpoint | string | undefined | Server handler URL for proxy mode. When provided, the plugin sends POST requests to this URL instead of fetching CRL/OCSP directly. Omit for direct mode (Node.js). |
timeout | number | 10000 | HTTP request timeout in milliseconds. In proxy mode, this is the timeout for the POST request to the server handler. In direct mode, this is the timeout for each individual CRL/OCSP fetch. |
crl | boolean | true | Enable CRL (Certificate Revocation List) checking. Set to false to disable CRL checks entirely. |
ocsp | boolean | true | Enable OCSP (Online Certificate Status Protocol) checking. Set to false to disable OCSP checks entirely. |
maxCrlSize | number | 10485760 | Maximum size of a downloaded CRL or OCSP response, in bytes (default: 10 MB). Only applies in direct mode. In proxy mode, the server handler's maxCrlSize option controls this. |
headers | Record<string, string> | () => Record<string, string> | undefined | Custom headers for proxy requests (browser mode only). Pass a static object or a function that returns headers dynamically (useful for auth tokens that expire). Headers are merged after the default Content-Type: application/json. |
onError | (error: Error, context: { type: 'crl' | 'ocsp'; url: string }) => void | undefined | Error callback invoked when a download fails (timeout, network error, an unexpected status from the proxy). context.type is 'crl' or 'ocsp'. context.url is the endpoint URL in proxy mode, the CA's URL in direct mode. |
HandlerOptions
Options passed to handleRevocation(options?), expressHandler(options?), and processRevocation(payload, options?).
interface HandlerOptions {
timeout?: number
maxCrlSize?: number
urlFilter?: (url: string) => boolean
}| Option | Type | Default | Description |
|---|---|---|---|
timeout | number | 10000 | Timeout in milliseconds for each outgoing CRL/OCSP fetch. If a CRL endpoint or OCSP responder does not respond within this time, the request is aborted. |
maxCrlSize | number | 10485760 | Maximum size of a downloaded CRL or OCSP response, in bytes (default: 10 MB), checked against the Content-Length header and the actual body length. A larger response is discarded. |
urlFilter | (url: string) => boolean | See SSRF Protection | Filter function for SSRF protection. Called with the URL in the request. Return true to allow the URL, false to block it. |
RevocationRequest
The payload sent from the browser plugin to the server handler. Also the first parameter of processRevocation().
type RevocationRequest = (
| { kind: 'crl'; url: string }
| { kind: 'ocsp'; url: string; body: string }
) & {
subject?: string
}| Field | Type | Required | Description |
|---|---|---|---|
kind | 'crl' | 'ocsp' | Yes | What to download. |
url | string | Yes | The CRL distribution point, or the OCSP responder, named in the certificate. |
body | string | For OCSP | The DER-encoded OCSP request, base64. Built by the engine. |
subject | string | No | Subject of the certificate being asked about. The handler ignores it; it is there so a server can log whose revocation was looked up. |
RevocationFetchRequest
What the engine passes to a plugin's revocation.fetch. Defined in @trexolab/certeno-core. The same as RevocationRequest, with the OCSP body as a Uint8Array.
CertificateInfo
Defined in @trexolab/certeno-core. The fields that drive online revocation checking, on each entry of sig.certificateChain:
interface CertificateInfo {
revocationStatus?: 'good' | 'revoked' | 'revokedAfterSigning' | 'revokedNoTimestamp' | 'unknown'
// 'unknown' = the document leaves this certificate unanswered
ocspRequest?: Uint8Array // the OCSP request to POST, when the issuer is known
ocspUrls?: string[] // OCSP responder URLs from the certificate
crlDistributionPoints?: string[] // CRL URLs from the certificate
// ... other fields omitted for brevity
}Opening a Document vs. Looking Again
| Asks the CA about | Triggered by | |
|---|---|---|
Opening (verify()) | Only the certificates the document leaves unanswered. An LTV-enabled document causes no requests. | Loading a file |
Looking again (verify(…, { revocation: 'online' })) | Every certificate in the chain, including those the document answers for | revalidate() in the React hook and the vanilla viewer; the signature panel's "Re-validate" button |
A document's own revocation data is a snapshot from around the day it was signed. Looking again is how a certificate revoked since then is noticed — and if that revocation falls after the signing time and no trusted timestamp fixes when the document was signed, the signature becomes invalid.
How a Certificate Gets Answered For
- The engine verifies the document and marks each chain certificate with what the document's own data establishes. Those reading
'unknown'are the ones to ask about. - OCSP first. If the certificate has
ocspUrlsand anocspRequest, the request is POSTed to each URL in turn until one returns a body. - The engine verifies again, now with the downloaded responses alongside the document's own.
- CRL for what is still unanswered — no responder, no response, or a response that did not hold up. The CRL is fetched from each of
crlDistributionPointsin turn, and the engine verifies once more. A certificate that has expired is the exception: its CRL is not fetched, because a CA drops expired certificates from its CRL and today's cannot clear one.
This order is fixed in the core engine and is not configurable from the plugin options. Each distinct download is made once per verification, however many signatures or certificates share it.
What Makes a Response Count
The engine applies the same rules to a downloaded response as to one embedded in the document:
- A CRL must be signed by the CA that issued the certificate.
- An OCSP response must be signed by that CA, or by a responder carrying the OCSPSigning extended key usage that was issued within the certificate's own chain; and its
CertIDmust identify the certificate by serial number and issuer key. - "Not revoked" must cover the moment the signature is judged at: not lapsed (
nextUpdate) by then, and issued while the certificate was still valid. - "Revoked" needs only the signature. The revocation date is then compared with the signing time: before it, the signature is invalid; after it, the signature stands only if a trusted timestamp proves when the document was signed.
A response that fails is ignored — the certificate stays 'unknown', and revocationCheck.attempted is set if it was the signer's.
Error Handling
| Scenario | Behavior | Effect | How to debug |
|---|---|---|---|
| Proxy request times out | AbortController aborts the fetch. onError is called. | That source yields nothing. | Increase timeout. Check server handler logs. |
| Proxy returns an unexpected status (not 200/403/502) | onError is called. | That source yields nothing. | Check the handler's response. Ensure it is mounted at the correct path and both sides run the same plugin version. |
| Proxy network error (server down, DNS failure) | Fetch throws. onError is called. | That source yields nothing. | Verify server is running. Check network connectivity. |
| CA endpoint unreachable, or answers non-2xx | The next URL for that certificate is tried. | Falls back from OCSP to CRL. | Check firewall rules. Try fetching the URL with curl. |
Response exceeds maxCrlSize | Discarded. | That source yields nothing. | Increase maxCrlSize. |
| Response is not signed by the certificate's CA or an authorised responder | The engine ignores it. | Certificate stays 'unknown'. | Something between you and the CA is answering in its place, or the CA's chain is incomplete on your side. |
| Response is about another certificate, has lapsed, or was issued after the certificate expired | The engine ignores it. | Certificate stays 'unknown'. | Expected for expired certificates: only revocation data from when they were valid can answer for them. |
No ocspRequest on the chain entry | OCSP is skipped; only the CRL is tried. | — | The issuer's certificate is not available. Complete the chain. |
| URL rejected by SSRF protection | No fetch attempted; handler answers 403. | That source yields nothing. | Customize urlFilter to allow the CA's endpoints. |
Request body is not a RevocationRequest (server handler) | Handler returns 400. | That source yields nothing. | Ensure express.json() is applied. Check that client and server run the same plugin version. |
In all error cases, the verification still completes. A certificate that could not be answered for keeps revocationStatus: 'unknown'; when it is the signer's, revocationCheck.attempted is true.
SSRF Protection
The server handlers (handleRevocation, expressHandler, processRevocation) apply a URL filter before fetching any external endpoint. This prevents attackers from using the revocation handler as an open proxy to access internal services.
Default filter rules:
The default urlFilter function applies a layered check. A URL is blocked if any of these conditions are true:
- The URL does not parse successfully (
new URL(url)throws). - The protocol is not
http:orhttps:. - The hostname resolves to a private or loopback address:
localhost,127.0.0.1,::1,0.0.0.0- RFC 1918 private ranges:
10.x.x.x,172.16-31.x.x,192.168.x.x .localor.internalTLDs
If the URL passes the above checks, it is allowed if it matches any of these patterns (fast-path for known PKI URLs):
- Hostname or path contains
crl,ocsp,pki,ca., orcert - Path ends with
.crl,.cer, or.der - Path contains
/crl,/ocsp,/ca/,/revocation, or/repository - Hostname belongs to a government domain (
.gov,.mil,.gov.in,.nic.in)
If none of the above patterns match, the URL is still allowed by default (the filter falls through to return true). This means the default filter is permissive for all public URLs and only blocks private/loopback addresses. If you need stricter filtering, provide a custom urlFilter.
Custom filter:
handleRevocation({
urlFilter: (url) => {
try {
const u = new URL(url)
// Allow only specific CA domains
return u.hostname.endsWith('.digicert.com') ||
u.hostname.endsWith('.globalsign.com') ||
u.hostname.endsWith('.letsencrypt.org')
} catch {
return false
}
},
})Permissive filter (allow all HTTP/HTTPS URLs):
handleRevocation({
urlFilter: (url) => {
try {
const u = new URL(url)
return u.protocol === 'http:' || u.protocol === 'https:'
} catch {
return false
}
},
})UI Integration
When the revocation plugin updates a signature's revocationCheck field, the React viewer components (@trexolab/certeno-react) automatically reflect the result.
DocumentMessageBar
The bar at the top of the viewer. If any signature's overallStatus becomes 'invalid' due to revocation, the bar displays: "At least one signature is INVALID." with a red background.
SignatureListPanel
In the expanded details for each signature, a revocation bullet point appears:
| Plugin result | Bullet text | Status icon |
|---|---|---|
'good' | "Certificate is not revoked" | Green checkmark |
'revoked' / 'revokedNoTimestamp' | "Certificate has been revoked" | Red X |
'unknown' | "Revocation status unknown" | Gray question mark |
Signature Properties Dialog (ValidityChecklist)
The full checklist in the properties dialog shows a "Revocation Status" row:
| Plugin result | Check text | Detail |
|---|---|---|
'good' | "Certificate is not revoked (verified via online OCSP)." or "Certificate is not revoked (verified via online CRL)." | Source URL |
'revoked' | "The signer's certificate has been revoked." | Revocation date and reason if available |
'revokedAfterSigning' | "Certificate is not revoked (verified via revoked after signing, timestamp protects)." | Source |
'unknown' | "Certificate revocation status is unknown." | Detail from revocationCheck.detail |
LTV Status
A signature is "LTV enabled" (sig.ltvEnabled) when its chain is trusted and the document itself carries verifiable revocation data for every certificate below the trust anchor — in the signature (adbe-revocationInfoArchival) or in the DSS. The SignatureListPanel then displays "Signature is LTV enabled."
This plugin does not change it. An answer fetched online settles a certificate's status today, but it is not in the file, so the file is no more able to vouch for itself than before. Neither a timestamp nor an ETSI SubFilter is required: Acrobat's own adbe.pkcs7.detached signatures are LTV enabled when Acrobat embedded the whole chain's CRLs.
Where the chain ends matters. The same file can be LTV enabled for one verifier and not for another: if an intermediate CA is itself a trust anchor, nothing above it needs answering for; if trust starts at the root, the intermediate's revocation data has to be in the file too. Certeno trusts roots, as Acrobat does with its default (AATL) trust list.