micro509 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -30
- package/dist/crypto/crypto.d.ts +73 -0
- package/dist/crypto/crypto.js +74 -0
- package/dist/crypto/crypto.js.map +1 -0
- package/dist/crypto.d.ts +4 -0
- package/dist/crypto.js +2 -0
- package/dist/der/der.d.ts +1 -1
- package/dist/index.d.ts +13 -9
- package/dist/index.js +17 -15
- package/dist/internal/asn1/asn1.js +21 -10
- package/dist/internal/asn1/asn1.js.map +1 -1
- package/dist/internal/asn1/der.d.ts +4 -2
- package/dist/internal/asn1/der.js +18 -5
- package/dist/internal/asn1/der.js.map +1 -1
- package/dist/internal/asn1/oids.js +7 -1
- package/dist/internal/crypto/algorithm-names.js +4 -0
- package/dist/internal/crypto/algorithm-names.js.map +1 -1
- package/dist/internal/crypto/pbes2.d.ts +38 -0
- package/dist/internal/crypto/pbes2.js +9 -10
- package/dist/internal/crypto/pbes2.js.map +1 -1
- package/dist/internal/crypto/rsa-pss.js +2 -0
- package/dist/internal/crypto/rsa-pss.js.map +1 -1
- package/dist/internal/crypto/sig-verify.d.ts +31 -0
- package/dist/internal/crypto/sig-verify.js +10 -8
- package/dist/internal/crypto/sig-verify.js.map +1 -1
- package/dist/internal/shared/base64.js +7 -1
- package/dist/internal/shared/base64.js.map +1 -1
- package/dist/internal/shared/dn.d.ts +16 -0
- package/dist/internal/shared/dn.js +13 -6
- package/dist/internal/shared/dn.js.map +1 -1
- package/dist/internal/shared/ip.d.ts +69 -0
- package/dist/internal/shared/ip.js +18 -1
- package/dist/internal/shared/ip.js.map +1 -1
- package/dist/internal/verify/verify-path.d.ts +7 -0
- package/dist/internal/verify/verify-path.js +36 -36
- package/dist/internal/x509/directory-name.js +24 -0
- package/dist/internal/x509/directory-name.js.map +1 -0
- package/dist/internal/x509/extension-bits.js +13 -10
- package/dist/internal/x509/extension-bits.js.map +1 -1
- package/dist/internal/x509/extension-errors.d.ts +6 -0
- package/dist/internal/x509/extension-errors.js +20 -0
- package/dist/internal/x509/extension-errors.js.map +1 -0
- package/dist/internal/x509/extension-registry.js +113 -55
- package/dist/internal/x509/extension-registry.js.map +1 -1
- package/dist/internal/x509/general-name-tags.js +28 -0
- package/dist/internal/x509/general-name-tags.js.map +1 -0
- package/dist/internal/x509/general-name.js +97 -0
- package/dist/internal/x509/general-name.js.map +1 -0
- package/dist/internal/x509/name-fields.js +20 -10
- package/dist/internal/x509/name-fields.js.map +1 -1
- package/dist/keys/keys.d.ts +16 -2
- package/dist/keys/keys.js +311 -170
- package/dist/keys/keys.js.map +1 -1
- package/dist/keys.d.ts +3 -2
- package/dist/keys.js +3 -2
- package/dist/pem/pem.d.ts +3 -2
- package/dist/pem/pem.js +112 -30
- package/dist/pem/pem.js.map +1 -1
- package/dist/pkcs/pkcs12-mac.js +3 -3
- package/dist/pkcs/pkcs12-mac.js.map +1 -1
- package/dist/pkcs/pkcs7.d.ts +85 -21
- package/dist/pkcs/pkcs7.js +261 -186
- package/dist/pkcs/pkcs7.js.map +1 -1
- package/dist/pkcs.d.ts +2 -2
- package/dist/result/result.d.ts +18 -10
- package/dist/result/result.js +20 -12
- package/dist/result/result.js.map +1 -1
- package/dist/result.d.ts +2 -2
- package/dist/result.js +2 -2
- package/dist/revocation/chain.js +77 -81
- package/dist/revocation/chain.js.map +1 -1
- package/dist/revocation/crl.d.ts +13 -2
- package/dist/revocation/crl.js +415 -236
- package/dist/revocation/crl.js.map +1 -1
- package/dist/revocation/ocsp.d.ts +58 -17
- package/dist/revocation/ocsp.js +185 -173
- package/dist/revocation/ocsp.js.map +1 -1
- package/dist/revocation/revocation.d.ts +4 -4
- package/dist/revocation/revocation.js +48 -30
- package/dist/revocation/revocation.js.map +1 -1
- package/dist/revocation.d.ts +4 -4
- package/dist/revocation.js +5 -5
- package/dist/verify/identity.d.ts +2 -1
- package/dist/verify/identity.js +2 -1
- package/dist/verify/identity.js.map +1 -1
- package/dist/verify/policy.d.ts +6 -1
- package/dist/verify/verify.d.ts +4 -2
- package/dist/verify/verify.js +32 -14
- package/dist/verify/verify.js.map +1 -1
- package/dist/verify.d.ts +2 -1
- package/dist/verify.js +4 -3
- package/dist/x509/certificate.d.ts +36 -13
- package/dist/x509/certificate.js +36 -19
- package/dist/x509/certificate.js.map +1 -1
- package/dist/x509/csr.d.ts +6 -3
- package/dist/x509/extensions.d.ts +58 -21
- package/dist/x509/extensions.js +384 -117
- package/dist/x509/extensions.js.map +1 -1
- package/dist/x509/name-text.js +2 -0
- package/dist/x509/name-text.js.map +1 -1
- package/dist/x509/name.d.ts +8 -5
- package/dist/x509/name.js +17 -12
- package/dist/x509/name.js.map +1 -1
- package/dist/x509/parse.d.ts +104 -18
- package/dist/x509/parse.js +127 -163
- package/dist/x509/parse.js.map +1 -1
- package/dist/x509.d.ts +8 -5
- package/dist/x509.js +10 -8
- package/package.json +28 -20
package/dist/revocation/chain.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parseCertificateFromSource as e } from "../x509/parse.js";
|
|
2
|
-
import { checkCertificateRevocationAgainstCrl as t,
|
|
3
|
-
import { verifyCertificateChain as
|
|
4
|
-
import { parseOcspResponseDerOrThrow as
|
|
2
|
+
import { checkCertificateRevocationAgainstCrl as t, coversAllDistributionPointReasons as n, parseCertificateRevocationListDerOrThrow as r, parseCertificateRevocationListPemOrThrow as i, revocationReasonFromCode as a } from "./crl.js";
|
|
3
|
+
import { verifyCertificateChain as o } from "../verify/verify.js";
|
|
4
|
+
import { parseOcspResponseDerOrThrow as s, parseOcspResponsePemOrThrow as c, validateOcspResponse as l } from "./ocsp.js";
|
|
5
5
|
//#region src/revocation/chain.ts
|
|
6
6
|
/**
|
|
7
7
|
* Granular reasons why revocation status could not be determined.
|
|
@@ -16,7 +16,7 @@ import { parseOcspResponseDerOrThrow as o, parseOcspResponsePemOrThrow as s, val
|
|
|
16
16
|
* `crl_signer_revoked`, `crl_signer_indeterminate`, and OCSP equivalents
|
|
17
17
|
* - **Freshness**: `crl_expired`, `ocsp_response_expired`
|
|
18
18
|
*/
|
|
19
|
-
const
|
|
19
|
+
const u = [
|
|
20
20
|
"no_applicable_crl",
|
|
21
21
|
"no_applicable_ocsp",
|
|
22
22
|
"distribution_point_mismatch",
|
|
@@ -40,7 +40,7 @@ const l = [
|
|
|
40
40
|
* Parses a CRL from various source formats.
|
|
41
41
|
*/
|
|
42
42
|
function parseCrlFromSource(e) {
|
|
43
|
-
return typeof e == "object" && "issuer" in e ? e : typeof e == "string" ?
|
|
43
|
+
return typeof e == "object" && "issuer" in e ? e : typeof e == "string" ? i(e) : r(e);
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Parses a certificate from various source formats, returning undefined on failure.
|
|
@@ -94,8 +94,8 @@ async function crlSignerChainsToAnchor(e, t, n, r) {
|
|
|
94
94
|
if (t.some((t) => sameCertificate(t, e))) return !0;
|
|
95
95
|
let i = t[t.length - 1];
|
|
96
96
|
if (i === void 0) return !1;
|
|
97
|
-
let
|
|
98
|
-
sameCertificate(t, e) || sameCertificate(t, i) ||
|
|
97
|
+
let a = [], addCandidate = (t) => {
|
|
98
|
+
sameCertificate(t, e) || sameCertificate(t, i) || a.some((e) => sameCertificate(e, t)) || a.push(t);
|
|
99
99
|
};
|
|
100
100
|
for (let e = 0; e < t.length - 1; e += 1) {
|
|
101
101
|
let n = t[e];
|
|
@@ -105,9 +105,9 @@ async function crlSignerChainsToAnchor(e, t, n, r) {
|
|
|
105
105
|
let t = parseCertificateSafe(e);
|
|
106
106
|
t !== void 0 && addCandidate(t);
|
|
107
107
|
}
|
|
108
|
-
return (await
|
|
108
|
+
return (await o({
|
|
109
109
|
leaf: e.der,
|
|
110
|
-
intermediates:
|
|
110
|
+
intermediates: a.map((e) => e.der),
|
|
111
111
|
roots: [i.der],
|
|
112
112
|
at: r
|
|
113
113
|
})).ok;
|
|
@@ -152,27 +152,41 @@ function findSignerIssuer(e, t) {
|
|
|
152
152
|
* Checks if a CRL signer certificate is revoked by examining available CRLs.
|
|
153
153
|
* Recursively validates the CRL signer of any CRL used to check revocation.
|
|
154
154
|
*/
|
|
155
|
-
async function checkSignerRevocation(e,
|
|
156
|
-
let i = r.chain.some((e) => sameCertificate(e,
|
|
157
|
-
for (let
|
|
158
|
-
let
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
} catch {
|
|
162
|
-
continue;
|
|
163
|
-
}
|
|
164
|
-
let o = await t({
|
|
165
|
-
certificate: e,
|
|
166
|
-
issuerCertificate: n,
|
|
167
|
-
crl: a,
|
|
168
|
-
at: r.at
|
|
169
|
-
});
|
|
170
|
-
if (o.ok) {
|
|
171
|
-
if (o.value.status === "revoked") return "resolved-revoked";
|
|
172
|
-
if (o.value.status === "good" && await validateCrlSigner(n, r) === "resolved-valid") return "resolved-valid";
|
|
173
|
-
}
|
|
155
|
+
async function checkSignerRevocation(e, t, r) {
|
|
156
|
+
let i = r.chain.some((e) => sameCertificate(e, t)), a = /* @__PURE__ */ new Set();
|
|
157
|
+
for (let n of r.crls) {
|
|
158
|
+
let i = await checkSignerAgainstCrl(e, t, n, r);
|
|
159
|
+
if (i.kind === "revoked") return "resolved-revoked";
|
|
160
|
+
for (let e of i.reasons) a.add(e);
|
|
174
161
|
}
|
|
175
|
-
return i ? "resolved-valid" : "resolved-indeterminate";
|
|
162
|
+
return n(a) || i ? "resolved-valid" : "resolved-indeterminate";
|
|
163
|
+
}
|
|
164
|
+
const d = {
|
|
165
|
+
kind: "reasons",
|
|
166
|
+
reasons: []
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Evaluates one CRL against a signer. A CRL that does not parse, does not
|
|
170
|
+
* apply, or is itself signed by a signer that is not known good yields no
|
|
171
|
+
* evidence rather than a verdict.
|
|
172
|
+
*/
|
|
173
|
+
async function checkSignerAgainstCrl(e, n, r, i) {
|
|
174
|
+
let a;
|
|
175
|
+
try {
|
|
176
|
+
a = parseCrlFromSource(r);
|
|
177
|
+
} catch {
|
|
178
|
+
return d;
|
|
179
|
+
}
|
|
180
|
+
let o = await t({
|
|
181
|
+
certificate: e,
|
|
182
|
+
issuerCertificate: n,
|
|
183
|
+
crl: a,
|
|
184
|
+
at: i.at
|
|
185
|
+
});
|
|
186
|
+
return o.ok ? o.value.status === "revoked" ? { kind: "revoked" } : await validateCrlSigner(n, i) === "resolved-valid" ? {
|
|
187
|
+
kind: "reasons",
|
|
188
|
+
reasons: o.value.coveredReasons
|
|
189
|
+
} : d : d;
|
|
176
190
|
}
|
|
177
191
|
/** Builds the `revoked` CertificateRevocationStatus for a CRL hit. */
|
|
178
192
|
function buildCrlRevokedStatus(e, t, n, r, i) {
|
|
@@ -192,7 +206,7 @@ function buildCrlRevokedStatus(e, t, n, r, i) {
|
|
|
192
206
|
}
|
|
193
207
|
/** Parses an OCSP response from PEM string or DER bytes. */
|
|
194
208
|
function parseOcspResponseFromSource(e) {
|
|
195
|
-
return typeof e == "string" ?
|
|
209
|
+
return typeof e == "string" ? c(e) : s(e);
|
|
196
210
|
}
|
|
197
211
|
/** Maps a {@linkcode validateOcspResponse} failure code to an indeterminate reason. */
|
|
198
212
|
function ocspIndeterminateReasonFromFailure(e) {
|
|
@@ -208,10 +222,11 @@ function ocspIndeterminateReasonFromFailure(e) {
|
|
|
208
222
|
case "issuer_mismatch":
|
|
209
223
|
case "nonce_mismatch":
|
|
210
224
|
case "request_mismatch": return "no_applicable_ocsp";
|
|
225
|
+
default: throw Error(`Unhandled ValidateOcspResponse failure code: ${String(e)}`);
|
|
211
226
|
}
|
|
212
227
|
}
|
|
213
228
|
/** Validation failures worth retrying with an explicit responder certificate. */
|
|
214
|
-
const
|
|
229
|
+
const f = /* @__PURE__ */ new Set([
|
|
215
230
|
"signature_invalid",
|
|
216
231
|
"responder_id_mismatch",
|
|
217
232
|
"responder_chain_invalid",
|
|
@@ -228,15 +243,15 @@ async function validateOcspResponseWithResponderFallback(e, t, n, r) {
|
|
|
228
243
|
...n.trustedOcspResponders === void 0 ? {} : { trustedOcspResponders: n.trustedOcspResponders },
|
|
229
244
|
...n.policy?.ocspResponderRevocation === void 0 ? {} : { responderRevocationPolicy: n.policy.ocspResponderRevocation },
|
|
230
245
|
...n.crls === void 0 ? {} : { responderRevocationCrls: n.crls }
|
|
231
|
-
}, a = await
|
|
246
|
+
}, a = await l({
|
|
232
247
|
response: e,
|
|
233
248
|
...i
|
|
234
249
|
});
|
|
235
|
-
if (a.ok || !
|
|
250
|
+
if (a.ok || !f.has(a.code)) return a;
|
|
236
251
|
for (let t of n.extraCertificates ?? []) {
|
|
237
252
|
let n = parseCertificateSafe(t);
|
|
238
253
|
if (n === void 0) continue;
|
|
239
|
-
let r = await
|
|
254
|
+
let r = await l({
|
|
240
255
|
response: e,
|
|
241
256
|
...i,
|
|
242
257
|
responderCertificate: n
|
|
@@ -255,7 +270,7 @@ async function validateOcspResponseWithResponderFallback(e, t, n, r) {
|
|
|
255
270
|
* sufficient to attribute the entry to `cert`.
|
|
256
271
|
*/
|
|
257
272
|
async function evaluateOcspEvidence(e, t, n) {
|
|
258
|
-
let { ocspResponses: r = [], at:
|
|
273
|
+
let { ocspResponses: r = [], at: i = /* @__PURE__ */ new Date() } = n, o = [], s = /* @__PURE__ */ new Set();
|
|
259
274
|
for (let c of r) {
|
|
260
275
|
let r;
|
|
261
276
|
try {
|
|
@@ -269,13 +284,13 @@ async function evaluateOcspEvidence(e, t, n) {
|
|
|
269
284
|
}
|
|
270
285
|
let l = (r.responses ?? []).find((t) => normalizeHex(t.certId.serialNumberHex) === normalizeHex(e.serialNumberHex));
|
|
271
286
|
if (l === void 0) continue;
|
|
272
|
-
let u = await validateOcspResponseWithResponderFallback(r, t, n,
|
|
287
|
+
let u = await validateOcspResponseWithResponderFallback(r, t, n, i);
|
|
273
288
|
if (!u.ok) {
|
|
274
289
|
s.add(ocspIndeterminateReasonFromFailure(u.code));
|
|
275
290
|
continue;
|
|
276
291
|
}
|
|
277
292
|
if (l.certStatus === "revoked") {
|
|
278
|
-
let t =
|
|
293
|
+
let t = a(l.revocationReasonCode);
|
|
279
294
|
return {
|
|
280
295
|
status: {
|
|
281
296
|
certificate: e,
|
|
@@ -315,25 +330,6 @@ async function evaluateOcspEvidence(e, t, n) {
|
|
|
315
330
|
};
|
|
316
331
|
}
|
|
317
332
|
/**
|
|
318
|
-
* Evaluates revocation status for a single certificate using available CRLs.
|
|
319
|
-
* Returns both status and any execution errors encountered.
|
|
320
|
-
*
|
|
321
|
-
* Tries the chain issuer first; if that fails, searches extraCertificates
|
|
322
|
-
* and chain for an indirect CRL issuer that matches the CRL's AKI or issuer DN.
|
|
323
|
-
*
|
|
324
|
-
* Also validates that CRL signers are not revoked (RFC 5280 §6.3.3).
|
|
325
|
-
*/
|
|
326
|
-
const d = [
|
|
327
|
-
"keyCompromise",
|
|
328
|
-
"cACompromise",
|
|
329
|
-
"affiliationChanged",
|
|
330
|
-
"superseded",
|
|
331
|
-
"cessationOfOperation",
|
|
332
|
-
"certificateHold",
|
|
333
|
-
"privilegeWithdrawn",
|
|
334
|
-
"aACompromise"
|
|
335
|
-
];
|
|
336
|
-
/**
|
|
337
333
|
* Runs each candidate signer through the full pipeline for one base CRL:
|
|
338
334
|
* signature/applicability, RFC 5280 §6.3.3(f) path to the anchor, then signer
|
|
339
335
|
* revocation. A candidate that verifies the signature but fails a later step
|
|
@@ -360,62 +356,62 @@ async function resolveBaseCrlAgainstSigners(e) {
|
|
|
360
356
|
continue;
|
|
361
357
|
}
|
|
362
358
|
if (a.value.status === "revoked") return buildCrlRevokedStatus(t, e, i, a.value.revocationDate, a.value.reasonCode);
|
|
363
|
-
recordGoodCrlEvidence(u, e, i,
|
|
359
|
+
recordGoodCrlEvidence(u, e, i, a.value.coveredReasons);
|
|
364
360
|
return;
|
|
365
361
|
}
|
|
366
362
|
}
|
|
367
|
-
async function evaluateCrlEvidence(e, t,
|
|
368
|
-
let { crls:
|
|
363
|
+
async function evaluateCrlEvidence(e, t, r, i) {
|
|
364
|
+
let { crls: a = [], extraCertificates: o = [], chain: s = [], at: c = /* @__PURE__ */ new Date() } = r, l = {
|
|
369
365
|
executionErrors: [],
|
|
370
366
|
coveredReasons: /* @__PURE__ */ new Set(),
|
|
371
367
|
sawCrlSignerRevoked: !1,
|
|
372
368
|
sawCrlSignerIndeterminate: !1,
|
|
373
369
|
sawCrlSignerNotAuthorized: !1,
|
|
374
370
|
sawGood: !1
|
|
375
|
-
},
|
|
376
|
-
for (let n of
|
|
377
|
-
let
|
|
371
|
+
}, u = parseCrlEvidenceSources(a, l.executionErrors), d = u.filter((e) => e.baseCrlNumber === void 0), f = u.filter((e) => e.baseCrlNumber !== void 0);
|
|
372
|
+
for (let n of d) {
|
|
373
|
+
let r = findApplicableDeltaCrl(n, f), a = await resolveBaseCrlAgainstSigners({
|
|
378
374
|
cert: e,
|
|
379
375
|
baseCrl: n,
|
|
380
|
-
applicableDelta:
|
|
381
|
-
crlThisUpdate:
|
|
376
|
+
applicableDelta: r,
|
|
377
|
+
crlThisUpdate: r !== void 0 && r.thisUpdate.getTime() > n.thisUpdate.getTime() ? r.thisUpdate : n.thisUpdate,
|
|
382
378
|
issuer: t,
|
|
383
|
-
extraCertificates:
|
|
384
|
-
chain:
|
|
385
|
-
at:
|
|
386
|
-
signerCtx:
|
|
387
|
-
state:
|
|
379
|
+
extraCertificates: o,
|
|
380
|
+
chain: s,
|
|
381
|
+
at: c,
|
|
382
|
+
signerCtx: i,
|
|
383
|
+
state: l
|
|
388
384
|
});
|
|
389
|
-
if (
|
|
390
|
-
status:
|
|
391
|
-
executionErrors:
|
|
385
|
+
if (a !== void 0) return {
|
|
386
|
+
status: a,
|
|
387
|
+
executionErrors: l.executionErrors
|
|
392
388
|
};
|
|
393
389
|
}
|
|
394
|
-
return
|
|
390
|
+
return l.sawGood && l.freshestGood !== void 0 ? n(l.coveredReasons) ? {
|
|
395
391
|
status: {
|
|
396
392
|
certificate: e,
|
|
397
393
|
status: "good",
|
|
398
394
|
source: {
|
|
399
395
|
kind: "crl",
|
|
400
|
-
signerCertificate:
|
|
401
|
-
thisUpdate:
|
|
396
|
+
signerCertificate: l.freshestGood.signer,
|
|
397
|
+
thisUpdate: l.freshestGood.thisUpdate
|
|
402
398
|
}
|
|
403
399
|
},
|
|
404
|
-
executionErrors:
|
|
400
|
+
executionErrors: l.executionErrors
|
|
405
401
|
} : {
|
|
406
402
|
status: {
|
|
407
403
|
certificate: e,
|
|
408
404
|
status: "indeterminate",
|
|
409
405
|
indeterminateReasons: ["reason_coverage_incomplete"]
|
|
410
406
|
},
|
|
411
|
-
executionErrors:
|
|
407
|
+
executionErrors: l.executionErrors
|
|
412
408
|
} : {
|
|
413
409
|
status: {
|
|
414
410
|
certificate: e,
|
|
415
411
|
status: "indeterminate",
|
|
416
|
-
indeterminateReasons: [crlUnavailableReason(
|
|
412
|
+
indeterminateReasons: [crlUnavailableReason(l)]
|
|
417
413
|
},
|
|
418
|
-
executionErrors:
|
|
414
|
+
executionErrors: l.executionErrors
|
|
419
415
|
};
|
|
420
416
|
}
|
|
421
417
|
/** Most specific indeterminate reason when no CRL yielded a usable verdict. */
|
|
@@ -458,7 +454,7 @@ function recordGoodCrlEvidence(e, t, n, r) {
|
|
|
458
454
|
signer: t,
|
|
459
455
|
thisUpdate: n
|
|
460
456
|
});
|
|
461
|
-
for (let t of r
|
|
457
|
+
for (let t of r) e.coveredReasons.add(t);
|
|
462
458
|
}
|
|
463
459
|
/**
|
|
464
460
|
* Evaluates revocation status for a single certificate by combining OCSP and
|
|
@@ -553,6 +549,6 @@ async function checkChainRevocation(e) {
|
|
|
553
549
|
};
|
|
554
550
|
}
|
|
555
551
|
//#endregion
|
|
556
|
-
export {
|
|
552
|
+
export { u as REVOCATION_INDETERMINATE_REASONS, checkChainRevocation };
|
|
557
553
|
|
|
558
554
|
//# sourceMappingURL=chain.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.js","names":[],"sources":["../../src/revocation/chain.ts"],"sourcesContent":["/**\n * Chain-level revocation orchestration.\n *\n * Evaluates CRL and OCSP evidence for an entire validated certificate chain,\n * implementing the revocation checking portion of RFC 5280 §6.3.\n *\n * @see {@link https://datatracker.ietf.org/doc/html/rfc5280#section-6.3 | RFC 5280 §6.3 CRL Validation}\n * @module\n */\n\nimport type {\n\tCrlSource,\n\tParsedCertificateRevocationList,\n\tRevocationReason,\n} from '#micro509/revocation/crl';\nimport {\n\tcheckCertificateRevocationAgainstCrl,\n\tparseCertificateRevocationListDerOrThrow,\n\tparseCertificateRevocationListPemOrThrow,\n\trevocationReasonFromCode,\n} from '#micro509/revocation/crl';\nimport type {\n\tOcspResponderRevocationPolicy,\n\tParsedOcspResponse,\n\tValidateOcspResponseFailure,\n\tValidateOcspResponseResult,\n} from '#micro509/revocation/ocsp';\nimport {\n\tparseOcspResponseDerOrThrow,\n\tparseOcspResponsePemOrThrow,\n\tvalidateOcspResponse,\n} from '#micro509/revocation/ocsp';\nimport type { RevocationCertificateSource } from '#micro509/revocation/revocation';\nimport { verifyCertificateChain } from '#micro509/verify/verify';\nimport type { ParsedCertificate } from '#micro509/x509/parse';\nimport { parseCertificateFromSource } from '#micro509/x509/parse';\n\nexport type { CrlSource };\n\n// Input Types\n\n/**\n * OCSP response in any supported format.\n *\n * Accepts PEM string or DER bytes. Used for\n * {@linkcode CheckChainRevocationInput.ocspResponses}.\n */\nexport type OcspResponseSource = string | Uint8Array;\n\n/**\n * Revocation checking policy for {@linkcode checkChainRevocation}.\n *\n * Controls how indeterminate results (missing evidence, expired CRLs) affect\n * the final {@linkcode CheckChainRevocationValue.decision | decision}.\n */\nexport interface RevocationPolicy {\n\t/**\n\t * How to handle indeterminate status.\n\t *\n\t * - `'hard-fail'`: indeterminate certificates cause denial (default)\n\t * - `'soft-fail'`: indeterminate certificates are allowed — an explicit\n\t * availability/compatibility choice\n\t *\n\t * Revocation checking itself is opt-in: no check runs unless evidence is\n\t * supplied. Once it is, indeterminate status denies by default.\n\t */\n\treadonly mode?: 'soft-fail' | 'hard-fail';\n\t/**\n\t * Evidence preference when multiple sources are available.\n\t *\n\t * Both evidence kinds are always evaluated, and a validated `revoked`\n\t * verdict from either source wins regardless of preference (fail-closed).\n\t * Preference only decides which source's `good` verdict is reported when\n\t * both yield one.\n\t *\n\t * - `'best-available'`: the source with the fresher evidence — the later\n\t * `thisUpdate` on the validated OCSP entry or CRL — is reported; ties\n\t * favor OCSP (default)\n\t * - `'ocsp'`: prefer OCSP over CRL\n\t * - `'crl'`: prefer CRL over OCSP\n\t */\n\treadonly prefer?: 'ocsp' | 'crl' | 'best-available';\n\t/**\n\t * Revocation policy for delegated OCSP responder certificates\n\t * (RFC 6960 §4.2.2.2.1). Supplied CRLs double as responder revocation\n\t * evidence. Defaults to `'honor-nocheck'`.\n\t */\n\treadonly ocspResponderRevocation?: OcspResponderRevocationPolicy;\n}\n\n/** Input for {@linkcode checkChainRevocation}. */\nexport interface CheckChainRevocationInput {\n\t/** Validated certificate chain (leaf first, root last). */\n\treadonly chain: readonly ParsedCertificate[];\n\t/** CRLs to evaluate. */\n\treadonly crls?: readonly CrlSource[];\n\t/** OCSP responses to evaluate. */\n\treadonly ocspResponses?: readonly OcspResponseSource[];\n\t/** Extra certs for indirect CRL issuers / delegated OCSP responders. */\n\treadonly extraCertificates?: readonly RevocationCertificateSource[];\n\t/**\n\t * Explicitly trusted OCSP responder certificates (RFC 6960 §4.2.2.2\n\t * criterion 1). A response signed by one of these is accepted without\n\t * delegated-responder issuance, EKU, and revocation checks.\n\t */\n\treadonly trustedOcspResponders?: readonly RevocationCertificateSource[];\n\t/** Evaluation time. Defaults to `new Date()`. */\n\treadonly at?: Date;\n\t/** Revocation policy. */\n\treadonly policy?: RevocationPolicy;\n}\n\n// Output Types\n\n/**\n * Granular reasons why revocation status could not be determined.\n *\n * Returned in {@linkcode CertificateRevocationStatus}'s `indeterminateReasons`\n * when `status` is `'indeterminate'`. Grouped by category:\n *\n * - **Evidence not found**: `no_applicable_crl`, `no_applicable_ocsp`\n * - **Scope mismatch**: `distribution_point_mismatch`, `issuer_name_mismatch`,\n * `reason_scope_mismatch`, `indirect_crl_scope_mismatch`, `reason_coverage_incomplete`\n * - **Signer trust**: `crl_signer_not_found`, `crl_signer_not_authorized`,\n * `crl_signer_revoked`, `crl_signer_indeterminate`, and OCSP equivalents\n * - **Freshness**: `crl_expired`, `ocsp_response_expired`\n */\nexport const REVOCATION_INDETERMINATE_REASONS = [\n\t// Evidence not found\n\t'no_applicable_crl',\n\t'no_applicable_ocsp',\n\t// Scope issues\n\t'distribution_point_mismatch',\n\t'issuer_name_mismatch',\n\t'reason_scope_mismatch',\n\t'indirect_crl_scope_mismatch',\n\t'reason_coverage_incomplete',\n\t// Signer trust issues\n\t'crl_signer_not_found',\n\t'crl_signer_not_authorized',\n\t'crl_signer_revoked',\n\t'crl_signer_indeterminate',\n\t'ocsp_responder_not_found',\n\t'ocsp_responder_not_authorized',\n\t'ocsp_responder_revoked',\n\t'ocsp_responder_indeterminate',\n\t// Freshness\n\t'crl_expired',\n\t'ocsp_response_expired',\n\t// OCSP specific\n\t'ocsp_status_unknown',\n] as const;\n\n/** See the doc comment above {@linkcode REVOCATION_INDETERMINATE_REASONS}. */\nexport type RevocationIndeterminateReason = (typeof REVOCATION_INDETERMINATE_REASONS)[number];\n\n/**\n * Identifies the source of revocation evidence.\n *\n * Included in {@linkcode CertificateRevocationStatus}'s `source` when status is\n * `'good'` or `'revoked'` to indicate which CRL or OCSP response provided the answer.\n */\nexport interface RevocationSource {\n\t/** Whether evidence came from a CRL or OCSP response. */\n\treadonly kind: 'crl' | 'ocsp';\n\t/** Certificate that signed the evidence (CRL issuer or OCSP responder). */\n\treadonly signerCertificate?: ParsedCertificate;\n\t/** Identifier for debugging (e.g., CRL issuer DN or OCSP responder URL). */\n\treadonly evidenceIdentifier?: string;\n\t/**\n\t * `thisUpdate` of the evidence backing the verdict — the OCSP single\n\t * response entry or the freshest contributing CRL (an applied delta CRL\n\t * supersedes its base). This is the timestamp `'best-available'` compares.\n\t */\n\treadonly thisUpdate?: Date;\n}\n\n/**\n * Revocation evaluation result for a single certificate.\n *\n * One entry per certificate in {@linkcode CheckChainRevocationValue.certificates}.\n * The trust anchor is excluded (never checked for revocation).\n */\nexport type CertificateRevocationStatus =\n\t| {\n\t\t\t/** The certificate that was evaluated. */\n\t\t\treadonly certificate: ParsedCertificate;\n\t\t\t/** Evidence confirms the certificate is not revoked. */\n\t\t\treadonly status: 'good';\n\t\t\t/** Evidence that produced the verdict. */\n\t\t\treadonly source: RevocationSource;\n\t\t\t/** Never present on a `good` verdict. */\n\t\t\treadonly indeterminateReasons?: undefined;\n\t\t\t/** Never present on a `good` verdict. */\n\t\t\treadonly revocationInfo?: undefined;\n\t }\n\t| {\n\t\t\t/** The certificate that was evaluated. */\n\t\t\treadonly certificate: ParsedCertificate;\n\t\t\t/** Evidence confirms the certificate is revoked. */\n\t\t\treadonly status: 'revoked';\n\t\t\t/** Evidence that produced the verdict. */\n\t\t\treadonly source: RevocationSource;\n\t\t\t/** Revocation details from the CRL entry or OCSP response. */\n\t\t\treadonly revocationInfo: {\n\t\t\t\t/** When the certificate was revoked. */\n\t\t\t\treadonly revocationDate: Date;\n\t\t\t\t/** RFC 5280 CRLReason code, if provided by the CRL/OCSP response. */\n\t\t\t\treadonly reason?: RevocationReason;\n\t\t\t};\n\t\t\t/** Never present on a `revoked` verdict. */\n\t\t\treadonly indeterminateReasons?: undefined;\n\t }\n\t| {\n\t\t\t/** The certificate that was evaluated. */\n\t\t\treadonly certificate: ParsedCertificate;\n\t\t\t/** Revocation status could not be determined. */\n\t\t\treadonly status: 'indeterminate';\n\t\t\t/** Why status could not be determined. */\n\t\t\treadonly indeterminateReasons: readonly RevocationIndeterminateReason[];\n\t\t\t/** Never present on an `indeterminate` verdict. */\n\t\t\treadonly source?: undefined;\n\t\t\t/** Never present on an `indeterminate` verdict. */\n\t\t\treadonly revocationInfo?: undefined;\n\t };\n\n/**\n * Errors encountered while processing revocation evidence.\n *\n * Distinct from {@linkcode RevocationIndeterminateReason}: execution errors are\n * code failures (malformed CRL, unsupported extension) rather than evaluation\n * outcomes (CRL doesn't cover this certificate).\n *\n * Collected in {@linkcode CheckChainRevocationValue.executionErrors}.\n */\nexport interface RevocationExecutionError {\n\t/** Error category. */\n\treadonly kind: 'parse_error' | 'unsupported_extension' | 'internal_error';\n\t/** Human-readable error description. */\n\treadonly message: string;\n\t/** Which evidence caused the error (e.g., CRL issuer DN). */\n\treadonly evidenceIdentifier?: string;\n}\n\n/**\n * Detailed revocation check results.\n *\n * Returned as {@linkcode CheckChainRevocationResult.value} from\n * {@linkcode checkChainRevocation}. Contains both the policy decision and\n * detailed per-certificate findings for debugging.\n */\nexport interface CheckChainRevocationValue {\n\t/**\n\t * Final policy decision based on {@linkcode RevocationPolicy}.\n\t *\n\t * - `'allow'`: chain passes revocation check\n\t * - `'deny'`: chain fails (revoked certificate or hard-fail on indeterminate)\n\t */\n\treadonly decision: 'allow' | 'deny';\n\t/** Quick-access summary of problematic certificates. */\n\treadonly summary: {\n\t\t/** Certificates confirmed as revoked. */\n\t\treadonly revokedCertificates: readonly ParsedCertificate[];\n\t\t/** Certificates whose status could not be determined. */\n\t\treadonly indeterminateCertificates: readonly ParsedCertificate[];\n\t};\n\t/** Per-certificate evaluation results. See {@linkcode CertificateRevocationStatus}. */\n\treadonly certificates: readonly CertificateRevocationStatus[];\n\t/** Evidence that could not be processed. See {@linkcode RevocationExecutionError}. */\n\treadonly executionErrors?: readonly RevocationExecutionError[];\n}\n\n/** Result type for {@linkcode checkChainRevocation}. */\nexport type CheckChainRevocationResult = {\n\treadonly ok: true;\n\treadonly value: CheckChainRevocationValue;\n};\n\n// Helpers\n\n/**\n * Parses a CRL from various source formats.\n */\nfunction parseCrlFromSource(source: CrlSource): ParsedCertificateRevocationList {\n\tif (typeof source === 'object' && 'issuer' in source) {\n\t\treturn source;\n\t}\n\tif (typeof source === 'string') {\n\t\treturn parseCertificateRevocationListPemOrThrow(source);\n\t}\n\treturn parseCertificateRevocationListDerOrThrow(source);\n}\n\n/**\n * Parses a certificate from various source formats, returning undefined on failure.\n */\nfunction parseCertificateSafe(source: RevocationCertificateSource): ParsedCertificate | undefined {\n\ttry {\n\t\treturn parseCertificateFromSource(source);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Compares two certificates by DER bytes for identity.\n * Reference equality fails when same cert is parsed from different sources.\n */\nfunction sameCertificate(a: ParsedCertificate, b: ParsedCertificate): boolean {\n\tif (a.der.length !== b.der.length) return false;\n\tfor (let i = 0; i < a.der.length; i++) {\n\t\tif (a.der[i] !== b.der[i]) return false;\n\t}\n\treturn true;\n}\n\n/**\n * Yields every certificate that could have signed the given CRL, AKI/SKI\n * matches before DN matches. All candidates are returned so a certificate whose\n * subject DN collides with the genuine CRL issuer cannot shadow it: each is\n * tried against the CRL signature and its own path to the trust anchor.\n */\nfunction findIndirectCrlIssuers(\n\tcrl: ParsedCertificateRevocationList,\n\textraCertificates: readonly RevocationCertificateSource[],\n\tchain: readonly ParsedCertificate[],\n): readonly ParsedCertificate[] {\n\tconst parsedExtras: ParsedCertificate[] = [];\n\tfor (const source of extraCertificates) {\n\t\tconst parsed = parseCertificateSafe(source);\n\t\tif (parsed !== undefined) {\n\t\t\tparsedExtras.push(parsed);\n\t\t}\n\t}\n\n\tconst candidates = [...parsedExtras, ...chain];\n\tconst matches: ParsedCertificate[] = [];\n\tconst push = (candidate: ParsedCertificate): void => {\n\t\tif (!matches.some((existing) => sameCertificate(existing, candidate))) {\n\t\t\tmatches.push(candidate);\n\t\t}\n\t};\n\n\tif (crl.authorityKeyIdentifier !== undefined) {\n\t\tfor (const candidate of candidates) {\n\t\t\tif (\n\t\t\t\tcandidate.subjectKeyIdentifier !== undefined &&\n\t\t\t\tnormalizeHex(crl.authorityKeyIdentifier) === normalizeHex(candidate.subjectKeyIdentifier)\n\t\t\t) {\n\t\t\t\tpush(candidate);\n\t\t\t}\n\t\t}\n\t}\n\tfor (const candidate of candidates) {\n\t\tif (crl.issuer.derHex === candidate.subject.derHex) {\n\t\t\tpush(candidate);\n\t\t}\n\t}\n\n\treturn matches;\n}\n\n/** Lowercases a hex string for bytewise comparison. */\nfunction normalizeHex(value: string): string {\n\treturn value.toLowerCase();\n}\n\n/**\n * RFC 5280 §6.3.3(f): confirms the CRL issuer certificate has a valid\n * certification path to the same trust anchor as the certificate under test. A\n * signer already inside the validated chain is authorized by construction. The\n * path check runs without revocation to avoid unbounded recursion.\n */\nasync function crlSignerChainsToAnchor(\n\tsigner: ParsedCertificate,\n\tchain: readonly ParsedCertificate[],\n\textraCertificates: readonly RevocationCertificateSource[],\n\tat: Date,\n): Promise<boolean> {\n\tif (chain.some((c) => sameCertificate(c, signer))) {\n\t\treturn true;\n\t}\n\tconst trustAnchor = chain[chain.length - 1];\n\tif (trustAnchor === undefined) {\n\t\treturn false;\n\t}\n\t// The signer's issuer may be a validated chain certificate (a delegated\n\t// signer issued by an intermediate), so pool the non-anchor chain members\n\t// with the extras. Exclude the signer and the anchor.\n\tconst pool: ParsedCertificate[] = [];\n\tconst addCandidate = (parsed: ParsedCertificate): void => {\n\t\tif (sameCertificate(parsed, signer) || sameCertificate(parsed, trustAnchor)) {\n\t\t\treturn;\n\t\t}\n\t\tif (!pool.some((existing) => sameCertificate(existing, parsed))) {\n\t\t\tpool.push(parsed);\n\t\t}\n\t};\n\tfor (let index = 0; index < chain.length - 1; index += 1) {\n\t\tconst certificate = chain[index];\n\t\tif (certificate !== undefined) {\n\t\t\taddCandidate(certificate);\n\t\t}\n\t}\n\tfor (const source of extraCertificates) {\n\t\tconst parsed = parseCertificateSafe(source);\n\t\tif (parsed !== undefined) {\n\t\t\taddCandidate(parsed);\n\t\t}\n\t}\n\tconst result = await verifyCertificateChain({\n\t\tleaf: signer.der,\n\t\tintermediates: pool.map((certificate) => certificate.der),\n\t\troots: [trustAnchor.der],\n\t\tat,\n\t});\n\treturn result.ok;\n}\n\n// CRL Signer Validation (RFC 5280 §6.3.3)\n\n/**\n * State machine for CRL signer validation with memoization.\n * - `visiting`: Currently being checked (cycle detection)\n * - `resolved-valid`: Signer is not revoked\n * - `resolved-revoked`: Signer is revoked\n * - `resolved-indeterminate`: Can't determine signer status\n */\ntype SignerValidationState =\n\t| 'visiting'\n\t| 'resolved-valid'\n\t| 'resolved-revoked'\n\t| 'resolved-indeterminate';\n\n/** Context for CRL signer validation with memoization cache. */\ninterface SignerValidationContext {\n\treadonly cache: Map<string, SignerValidationState>;\n\treadonly chain: readonly ParsedCertificate[];\n\treadonly crls: readonly CrlSource[];\n\treadonly extraCertificates: readonly RevocationCertificateSource[];\n\treadonly at: Date;\n}\n\n/**\n * Builds a unique cache key for a certificate.\n * Uses issuer DN + serial number which uniquely identifies a cert.\n */\nfunction certCacheKey(cert: ParsedCertificate): string {\n\treturn `${cert.issuer.derHex}:${cert.serialNumberHex}`;\n}\n\n/**\n * Validates that a CRL signer certificate is not revoked.\n * Uses memoization to avoid redundant checks and detect cycles.\n */\nasync function validateCrlSigner(\n\tsigner: ParsedCertificate,\n\tctx: SignerValidationContext,\n): Promise<SignerValidationState> {\n\t// Use issuer+serial as cache key (unique per certificate)\n\tconst key = certCacheKey(signer);\n\tconst cached = ctx.cache.get(key);\n\n\t// Cycle detection: if we're already visiting this signer, it's indeterminate\n\tif (cached === 'visiting') {\n\t\treturn 'resolved-indeterminate';\n\t}\n\n\t// Return cached result if already resolved\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\t// Mark as visiting before recursive checks\n\tctx.cache.set(key, 'visiting');\n\n\t// Trust anchor (last in chain) is trusted by definition\n\tconst trustAnchor = ctx.chain[ctx.chain.length - 1];\n\tif (trustAnchor !== undefined && sameCertificate(signer, trustAnchor)) {\n\t\tctx.cache.set(key, 'resolved-valid');\n\t\treturn 'resolved-valid';\n\t}\n\n\t// If signer is in the validated chain, it's trusted\n\t// (Chain was already validated before revocation checking)\n\tconst isInChain = ctx.chain.some((c) => sameCertificate(c, signer));\n\tif (isInChain) {\n\t\tctx.cache.set(key, 'resolved-valid');\n\t\treturn 'resolved-valid';\n\t}\n\n\t// Signer is not in chain — need to check its revocation status\n\t// Find signer's issuer to perform revocation check\n\tconst signerIssuer = findSignerIssuer(signer, ctx);\n\tif (signerIssuer === undefined) {\n\t\tctx.cache.set(key, 'resolved-indeterminate');\n\t\treturn 'resolved-indeterminate';\n\t}\n\n\t// Check signer's revocation status (recursive)\n\tconst signerRevocation = await checkSignerRevocation(signer, signerIssuer, ctx);\n\tctx.cache.set(key, signerRevocation);\n\treturn signerRevocation;\n}\n\n/**\n * Finds the issuer certificate for a CRL signer.\n * Searches the chain and extraCertificates by AKI/SKI or DN matching.\n */\nfunction findSignerIssuer(\n\tsigner: ParsedCertificate,\n\tctx: SignerValidationContext,\n): ParsedCertificate | undefined {\n\t// Parse extra certificates\n\tconst parsedExtras: ParsedCertificate[] = [];\n\tfor (const source of ctx.extraCertificates) {\n\t\tconst parsed = parseCertificateSafe(source);\n\t\tif (parsed !== undefined) {\n\t\t\tparsedExtras.push(parsed);\n\t\t}\n\t}\n\n\tconst candidates = [...ctx.chain, ...parsedExtras];\n\n\tfor (const candidate of candidates) {\n\t\t// Match by AKI → SKI (preferred, more specific)\n\t\tif (\n\t\t\tsigner.authorityKeyIdentifier !== undefined &&\n\t\t\tcandidate.subjectKeyIdentifier !== undefined &&\n\t\t\tnormalizeHex(signer.authorityKeyIdentifier) === normalizeHex(candidate.subjectKeyIdentifier)\n\t\t) {\n\t\t\treturn candidate;\n\t\t}\n\n\t\t// Match by issuer DN → subject DN\n\t\tif (signer.issuer.derHex === candidate.subject.derHex) {\n\t\t\treturn candidate;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Checks if a CRL signer certificate is revoked by examining available CRLs.\n * Recursively validates the CRL signer of any CRL used to check revocation.\n */\nasync function checkSignerRevocation(\n\tsigner: ParsedCertificate,\n\tissuer: ParsedCertificate,\n\tctx: SignerValidationContext,\n): Promise<SignerValidationState> {\n\t// If the signer's issuer is in the validated chain, the signer is trusted\n\t// by virtue of being issued by a trusted CA. We only need to check if\n\t// it's explicitly revoked, not prove \"good\" status.\n\tconst issuerInChain = ctx.chain.some((c) => sameCertificate(c, issuer));\n\n\t// Try each CRL to check signer's revocation\n\tfor (const crlSource of ctx.crls) {\n\t\tlet crl: ParsedCertificateRevocationList;\n\t\ttry {\n\t\t\tcrl = parseCrlFromSource(crlSource);\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Check if this CRL can provide revocation info for the signer\n\t\tconst result = await checkCertificateRevocationAgainstCrl({\n\t\t\tcertificate: signer,\n\t\t\tissuerCertificate: issuer,\n\t\t\tcrl,\n\t\t\tat: ctx.at,\n\t\t});\n\n\t\tif (result.ok) {\n\t\t\tif (result.value.status === 'revoked') {\n\t\t\t\treturn 'resolved-revoked';\n\t\t\t}\n\t\t\tif (result.value.status === 'good') {\n\t\t\t\t// Before accepting this result, validate the CRL's signer\n\t\t\t\t// The CRL's signer is the issuer we just used\n\t\t\t\tconst crlSignerStatus = await validateCrlSigner(issuer, ctx);\n\t\t\t\tif (crlSignerStatus === 'resolved-valid') {\n\t\t\t\t\treturn 'resolved-valid';\n\t\t\t\t}\n\t\t\t\t// If CRL signer is revoked or indeterminate, can't trust this result\n\t\t\t}\n\t\t}\n\t}\n\n\t// If the signer's issuer is in the chain and we found no revocation,\n\t// trust the signer (issued by trusted CA, no evidence of revocation)\n\tif (issuerInChain) {\n\t\treturn 'resolved-valid';\n\t}\n\n\treturn 'resolved-indeterminate';\n}\n\n/** Builds the `revoked` CertificateRevocationStatus for a CRL hit. */\nfunction buildCrlRevokedStatus(\n\tcert: ParsedCertificate,\n\tsigner: ParsedCertificate,\n\tthisUpdate: Date,\n\trevocationDate: Date,\n\treasonCode?: RevocationReason,\n): CertificateRevocationStatus {\n\treturn {\n\t\tcertificate: cert,\n\t\tstatus: 'revoked',\n\t\tsource: { kind: 'crl', signerCertificate: signer, thisUpdate },\n\t\trevocationInfo: {\n\t\t\trevocationDate,\n\t\t\t...(reasonCode !== undefined ? { reason: reasonCode } : {}),\n\t\t},\n\t};\n}\n\n// OCSP Evidence Evaluation (RFC 6960)\n\n/** Per-certificate evidence evaluation outcome shared by the CRL and OCSP evaluators. */\ninterface EvidenceEvaluation {\n\treadonly status: CertificateRevocationStatus;\n\treadonly executionErrors: readonly RevocationExecutionError[];\n}\n\n/** Parses an OCSP response from PEM string or DER bytes. */\nfunction parseOcspResponseFromSource(source: OcspResponseSource): ParsedOcspResponse {\n\tif (typeof source === 'string') {\n\t\treturn parseOcspResponsePemOrThrow(source);\n\t}\n\treturn parseOcspResponseDerOrThrow(source);\n}\n\n/** Maps a {@linkcode validateOcspResponse} failure code to an indeterminate reason. */\nfunction ocspIndeterminateReasonFromFailure(\n\tcode: ValidateOcspResponseFailure['code'],\n): RevocationIndeterminateReason {\n\tswitch (code) {\n\t\tcase 'stale_response':\n\t\t\treturn 'ocsp_response_expired';\n\t\tcase 'responder_id_mismatch':\n\t\tcase 'responder_chain_invalid':\n\t\tcase 'ocsp_signing_missing':\n\t\t\treturn 'ocsp_responder_not_authorized';\n\t\tcase 'responder_revoked':\n\t\t\treturn 'ocsp_responder_revoked';\n\t\tcase 'signature_invalid':\n\t\tcase 'responder_revocation_unknown':\n\t\t\treturn 'ocsp_responder_indeterminate';\n\t\tcase 'response_status_invalid':\n\t\tcase 'issuer_mismatch':\n\t\tcase 'nonce_mismatch':\n\t\tcase 'request_mismatch':\n\t\t\treturn 'no_applicable_ocsp';\n\t}\n}\n\n/** Validation failures worth retrying with an explicit responder certificate. */\nconst OCSP_RESPONDER_FAILURE_CODES: ReadonlySet<ValidateOcspResponseFailure['code']> = new Set([\n\t'signature_invalid',\n\t'responder_id_mismatch',\n\t'responder_chain_invalid',\n\t'ocsp_signing_missing',\n]);\n\n/**\n * Validates an OCSP response, retrying with caller-provided extra certificates\n * as explicit responder certificates when embedded discovery fails.\n */\nasync function validateOcspResponseWithResponderFallback(\n\tresponse: ParsedOcspResponse,\n\tissuer: ParsedCertificate,\n\tinput: CheckChainRevocationInput,\n\tat: Date,\n): Promise<ValidateOcspResponseResult> {\n\tconst shared = {\n\t\tissuerCertificate: issuer,\n\t\tat,\n\t\t...(input.trustedOcspResponders !== undefined\n\t\t\t? { trustedOcspResponders: input.trustedOcspResponders }\n\t\t\t: {}),\n\t\t...(input.policy?.ocspResponderRevocation !== undefined\n\t\t\t? { responderRevocationPolicy: input.policy.ocspResponderRevocation }\n\t\t\t: {}),\n\t\t// Chain-level CRLs double as responder revocation evidence\n\t\t...(input.crls !== undefined ? { responderRevocationCrls: input.crls } : {}),\n\t};\n\tconst primary = await validateOcspResponse({ response, ...shared });\n\tif (primary.ok || !OCSP_RESPONDER_FAILURE_CODES.has(primary.code)) {\n\t\treturn primary;\n\t}\n\tfor (const source of input.extraCertificates ?? []) {\n\t\tconst responder = parseCertificateSafe(source);\n\t\tif (responder === undefined) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst retry = await validateOcspResponse({\n\t\t\tresponse,\n\t\t\t...shared,\n\t\t\tresponderCertificate: responder,\n\t\t});\n\t\tif (retry.ok) {\n\t\t\treturn retry;\n\t\t}\n\t}\n\treturn primary;\n}\n\n/**\n * Evaluates OCSP evidence for a single certificate (RFC 6960).\n *\n * Every response is fully validated — signature, responder binding and\n * authorization, and freshness — via {@linkcode validateOcspResponse} before\n * its status entry is trusted. Issuer binding of each CertID is enforced by\n * the validator, so a serial-number match on a validated response is\n * sufficient to attribute the entry to `cert`.\n */\nasync function evaluateOcspEvidence(\n\tcert: ParsedCertificate,\n\tissuer: ParsedCertificate,\n\tinput: CheckChainRevocationInput,\n): Promise<EvidenceEvaluation> {\n\tconst { ocspResponses = [], at = new Date() } = input;\n\tconst executionErrors: RevocationExecutionError[] = [];\n\tconst reasons = new Set<RevocationIndeterminateReason>();\n\n\tfor (const source of ocspResponses) {\n\t\tlet parsed: ParsedOcspResponse;\n\t\ttry {\n\t\t\tparsed = parseOcspResponseFromSource(source);\n\t\t} catch (e) {\n\t\t\texecutionErrors.push({\n\t\t\t\tkind: 'parse_error',\n\t\t\t\tmessage: e instanceof Error ? e.message : 'OCSP response parse failed',\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst entry = (parsed.responses ?? []).find(\n\t\t\t(single) =>\n\t\t\t\tnormalizeHex(single.certId.serialNumberHex) === normalizeHex(cert.serialNumberHex),\n\t\t);\n\t\tif (entry === undefined) {\n\t\t\tcontinue; // Response does not cover this certificate\n\t\t}\n\n\t\tconst validation = await validateOcspResponseWithResponderFallback(parsed, issuer, input, at);\n\t\tif (!validation.ok) {\n\t\t\treasons.add(ocspIndeterminateReasonFromFailure(validation.code));\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (entry.certStatus === 'revoked') {\n\t\t\tconst reason = revocationReasonFromCode(entry.revocationReasonCode);\n\t\t\treturn {\n\t\t\t\tstatus: {\n\t\t\t\t\tcertificate: cert,\n\t\t\t\t\tstatus: 'revoked',\n\t\t\t\t\tsource: { kind: 'ocsp', thisUpdate: entry.thisUpdate },\n\t\t\t\t\trevocationInfo: {\n\t\t\t\t\t\trevocationDate: entry.revokedAt ?? entry.thisUpdate,\n\t\t\t\t\t\t...(reason !== undefined ? { reason } : {}),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\texecutionErrors,\n\t\t\t};\n\t\t}\n\t\tif (entry.certStatus === 'good') {\n\t\t\treturn {\n\t\t\t\tstatus: {\n\t\t\t\t\tcertificate: cert,\n\t\t\t\t\tstatus: 'good',\n\t\t\t\t\tsource: { kind: 'ocsp', thisUpdate: entry.thisUpdate },\n\t\t\t\t},\n\t\t\t\texecutionErrors,\n\t\t\t};\n\t\t}\n\t\treasons.add('ocsp_status_unknown');\n\t}\n\n\tif (reasons.size === 0) {\n\t\treasons.add('no_applicable_ocsp');\n\t}\n\treturn {\n\t\tstatus: {\n\t\t\tcertificate: cert,\n\t\t\tstatus: 'indeterminate',\n\t\t\tindeterminateReasons: [...reasons],\n\t\t},\n\t\texecutionErrors,\n\t};\n}\n\n/**\n * Evaluates revocation status for a single certificate using available CRLs.\n * Returns both status and any execution errors encountered.\n *\n * Tries the chain issuer first; if that fails, searches extraCertificates\n * and chain for an indirect CRL issuer that matches the CRL's AKI or issuer DN.\n *\n * Also validates that CRL signers are not revoked (RFC 5280 §6.3.3).\n */\n// RFC 5280 ReasonFlags — all possible revocation reasons that CRLs can cover.\nconst ALL_REASON_FLAGS: readonly string[] = [\n\t'keyCompromise',\n\t'cACompromise',\n\t'affiliationChanged',\n\t'superseded',\n\t'cessationOfOperation',\n\t'certificateHold',\n\t'privilegeWithdrawn',\n\t'aACompromise',\n];\n\ninterface CrlEvidenceState {\n\treadonly executionErrors: RevocationExecutionError[];\n\treadonly coveredReasons: Set<string>;\n\tsawCrlSignerRevoked: boolean;\n\tsawCrlSignerIndeterminate: boolean;\n\tsawCrlSignerNotAuthorized: boolean;\n\tsawGood: boolean;\n\tfreshestGood?: { readonly signer: ParsedCertificate; readonly thisUpdate: Date };\n}\n\n/** Inputs for resolving one base CRL against its candidate signers. */\ninterface BaseCrlResolution {\n\treadonly cert: ParsedCertificate;\n\treadonly baseCrl: ParsedCertificateRevocationList;\n\treadonly applicableDelta: ParsedCertificateRevocationList | undefined;\n\treadonly crlThisUpdate: Date;\n\treadonly issuer: ParsedCertificate;\n\treadonly extraCertificates: readonly RevocationCertificateSource[];\n\treadonly chain: readonly ParsedCertificate[];\n\treadonly at: Date;\n\treadonly signerCtx: SignerValidationContext;\n\treadonly state: CrlEvidenceState;\n}\n\n/**\n * Runs each candidate signer through the full pipeline for one base CRL:\n * signature/applicability, RFC 5280 §6.3.3(f) path to the anchor, then signer\n * revocation. A candidate that verifies the signature but fails a later step\n * does not shadow a subsequent usable signer, so the search continues. Returns\n * a revoked status when one is found; otherwise records good or diagnostic\n * evidence into `state`.\n */\nasync function resolveBaseCrlAgainstSigners(\n\tparams: BaseCrlResolution,\n): Promise<ReturnType<typeof buildCrlRevokedStatus> | undefined> {\n\tconst {\n\t\tcert,\n\t\tbaseCrl,\n\t\tapplicableDelta,\n\t\tcrlThisUpdate,\n\t\tissuer,\n\t\textraCertificates,\n\t\tchain,\n\t\tat,\n\t\tsignerCtx,\n\t\tstate,\n\t} = params;\n\tfor (const candidate of collectCrlSignerCandidates(baseCrl, issuer, extraCertificates, chain)) {\n\t\tconst checked = await checkCrlWithIssuer(cert, baseCrl, applicableDelta, candidate, at);\n\t\tif (!checked.ok) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (!(await crlSignerChainsToAnchor(candidate, chain, extraCertificates, at))) {\n\t\t\tstate.sawCrlSignerNotAuthorized = true;\n\t\t\tcontinue;\n\t\t}\n\t\tconst signerStatus = await validateCrlSigner(candidate, signerCtx);\n\t\tif (signerStatus === 'resolved-revoked') {\n\t\t\tstate.sawCrlSignerRevoked = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (signerStatus === 'resolved-indeterminate') {\n\t\t\tstate.sawCrlSignerIndeterminate = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (checked.value.status === 'revoked') {\n\t\t\treturn buildCrlRevokedStatus(\n\t\t\t\tcert,\n\t\t\t\tcandidate,\n\t\t\t\tcrlThisUpdate,\n\t\t\t\tchecked.value.revocationDate,\n\t\t\t\tchecked.value.reasonCode,\n\t\t\t);\n\t\t}\n\t\trecordGoodCrlEvidence(state, candidate, crlThisUpdate, baseCrl);\n\t\treturn undefined;\n\t}\n\treturn undefined;\n}\n\nasync function evaluateCrlEvidence(\n\tcert: ParsedCertificate,\n\tissuer: ParsedCertificate,\n\tinput: CheckChainRevocationInput,\n\tsignerCtx: SignerValidationContext,\n): Promise<EvidenceEvaluation> {\n\tconst { crls = [], extraCertificates = [], chain = [], at = new Date() } = input;\n\tconst state: CrlEvidenceState = {\n\t\texecutionErrors: [],\n\t\tcoveredReasons: new Set(),\n\t\tsawCrlSignerRevoked: false,\n\t\tsawCrlSignerIndeterminate: false,\n\t\tsawCrlSignerNotAuthorized: false,\n\t\tsawGood: false,\n\t};\n\n\t// Parse all CRLs and separate base CRLs from delta CRLs\n\tconst parsedCrls = parseCrlEvidenceSources(crls, state.executionErrors);\n\n\tconst baseCrls = parsedCrls.filter((crl) => crl.baseCrlNumber === undefined);\n\tconst deltaCrls = parsedCrls.filter((crl) => crl.baseCrlNumber !== undefined);\n\n\t// Process base CRLs (optionally paired with delta CRLs)\n\tfor (const baseCrl of baseCrls) {\n\t\tconst applicableDelta = findApplicableDeltaCrl(baseCrl, deltaCrls);\n\t\t// Evidence freshness: an applied delta CRL supersedes its base\n\t\tconst crlThisUpdate =\n\t\t\tapplicableDelta !== undefined &&\n\t\t\tapplicableDelta.thisUpdate.getTime() > baseCrl.thisUpdate.getTime()\n\t\t\t\t? applicableDelta.thisUpdate\n\t\t\t\t: baseCrl.thisUpdate;\n\t\tconst revoked = await resolveBaseCrlAgainstSigners({\n\t\t\tcert,\n\t\t\tbaseCrl,\n\t\t\tapplicableDelta,\n\t\t\tcrlThisUpdate,\n\t\t\tissuer,\n\t\t\textraCertificates,\n\t\t\tchain,\n\t\t\tat,\n\t\t\tsignerCtx,\n\t\t\tstate,\n\t\t});\n\t\tif (revoked !== undefined) {\n\t\t\treturn { status: revoked, executionErrors: state.executionErrors };\n\t\t}\n\t}\n\n\t// Return 'good' only if we saw at least one good result AND all reasons are covered\n\tif (state.sawGood && state.freshestGood !== undefined) {\n\t\tconst allReasonsCovered = ALL_REASON_FLAGS.every((r) => state.coveredReasons.has(r));\n\t\tif (allReasonsCovered) {\n\t\t\treturn {\n\t\t\t\tstatus: {\n\t\t\t\t\tcertificate: cert,\n\t\t\t\t\tstatus: 'good',\n\t\t\t\t\tsource: {\n\t\t\t\t\t\tkind: 'crl',\n\t\t\t\t\t\tsignerCertificate: state.freshestGood.signer,\n\t\t\t\t\t\tthisUpdate: state.freshestGood.thisUpdate,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\texecutionErrors: state.executionErrors,\n\t\t\t};\n\t\t}\n\t\t// Not all reasons covered — indeterminate\n\t\treturn {\n\t\t\tstatus: {\n\t\t\t\tcertificate: cert,\n\t\t\t\tstatus: 'indeterminate',\n\t\t\t\tindeterminateReasons: ['reason_coverage_incomplete'],\n\t\t\t},\n\t\t\texecutionErrors: state.executionErrors,\n\t\t};\n\t}\n\n\treturn {\n\t\tstatus: {\n\t\t\tcertificate: cert,\n\t\t\tstatus: 'indeterminate',\n\t\t\tindeterminateReasons: [crlUnavailableReason(state)],\n\t\t},\n\t\texecutionErrors: state.executionErrors,\n\t};\n}\n\n/** Most specific indeterminate reason when no CRL yielded a usable verdict. */\nfunction crlUnavailableReason(state: CrlEvidenceState): RevocationIndeterminateReason {\n\tif (state.sawCrlSignerRevoked) {\n\t\treturn 'crl_signer_revoked';\n\t}\n\tif (state.sawCrlSignerNotAuthorized) {\n\t\treturn 'crl_signer_not_authorized';\n\t}\n\tif (state.sawCrlSignerIndeterminate) {\n\t\treturn 'crl_signer_indeterminate';\n\t}\n\treturn 'no_applicable_crl';\n}\n\n/** Parses complete and delta CRL evidence while retaining source provenance. */\nfunction parseCrlEvidenceSources(\n\tcrls: readonly CrlSource[],\n\texecutionErrors: RevocationExecutionError[],\n): readonly ParsedCertificateRevocationList[] {\n\tconst parsedCrls: ParsedCertificateRevocationList[] = [];\n\tfor (const crlSource of crls) {\n\t\ttry {\n\t\t\tparsedCrls.push(parseCrlFromSource(crlSource));\n\t\t} catch (e) {\n\t\t\texecutionErrors.push({\n\t\t\t\tkind: 'parse_error',\n\t\t\t\tmessage: e instanceof Error ? e.message : 'CRL parse failed',\n\t\t\t});\n\t\t}\n\t}\n\treturn parsedCrls;\n}\n\nfunction findApplicableDeltaCrl(\n\tbaseCrl: ParsedCertificateRevocationList,\n\tdeltaCrls: readonly ParsedCertificateRevocationList[],\n): ParsedCertificateRevocationList | undefined {\n\treturn deltaCrls.find(\n\t\t(deltaCrl) =>\n\t\t\tdeltaCrl.issuer.derHex === baseCrl.issuer.derHex &&\n\t\t\tdeltaCrl.baseCrlNumber !== undefined &&\n\t\t\tbaseCrl.crlNumber !== undefined &&\n\t\t\tBigInt(deltaCrl.baseCrlNumber) <= BigInt(baseCrl.crlNumber),\n\t);\n}\n\n/** The direct issuer first, then deduplicated indirect CRL-issuer candidates. */\nfunction collectCrlSignerCandidates(\n\tbaseCrl: ParsedCertificateRevocationList,\n\tissuer: ParsedCertificate,\n\textraCertificates: readonly RevocationCertificateSource[],\n\tchain: readonly ParsedCertificate[],\n): readonly ParsedCertificate[] {\n\tconst candidates: ParsedCertificate[] = [issuer];\n\tfor (const indirect of findIndirectCrlIssuers(baseCrl, extraCertificates, chain)) {\n\t\tif (!candidates.some((existing) => sameCertificate(existing, indirect))) {\n\t\t\tcandidates.push(indirect);\n\t\t}\n\t}\n\treturn candidates;\n}\n\nfunction checkCrlWithIssuer(\n\tcert: ParsedCertificate,\n\tcrl: ParsedCertificateRevocationList,\n\tdeltaCrl: ParsedCertificateRevocationList | undefined,\n\tcrlIssuer: ParsedCertificate,\n\tat: Date,\n): ReturnType<typeof checkCertificateRevocationAgainstCrl> {\n\treturn checkCertificateRevocationAgainstCrl({\n\t\tcertificate: cert,\n\t\tissuerCertificate: crlIssuer,\n\t\tcrl,\n\t\t...(deltaCrl !== undefined ? { deltaCrl } : {}),\n\t\tat,\n\t});\n}\n\nfunction recordGoodCrlEvidence(\n\tstate: CrlEvidenceState,\n\tsigner: ParsedCertificate,\n\tthisUpdate: Date,\n\tbaseCrl: ParsedCertificateRevocationList,\n): void {\n\tstate.sawGood = true;\n\tif (\n\t\tstate.freshestGood === undefined ||\n\t\tthisUpdate.getTime() > state.freshestGood.thisUpdate.getTime()\n\t) {\n\t\tstate.freshestGood = { signer, thisUpdate };\n\t}\n\tfor (const reason of baseCrl.issuingDistributionPoint?.onlySomeReasons?.flags ??\n\t\tALL_REASON_FLAGS) {\n\t\tstate.coveredReasons.add(reason);\n\t}\n}\n\n/**\n * Evaluates revocation status for a single certificate by combining OCSP and\n * CRL evidence.\n *\n * Both evidence kinds are always evaluated: a validated `revoked` verdict from\n * either source wins regardless of {@linkcode RevocationPolicy.prefer}\n * (fail-closed). Otherwise the preferred source's `good` verdict is reported —\n * for `'best-available'` the source with the later evidence `thisUpdate` wins,\n * ties favoring OCSP. If neither source is definitive, indeterminate reasons\n * from both are merged.\n */\nasync function evaluateCertificateRevocation(\n\tcert: ParsedCertificate,\n\tissuer: ParsedCertificate,\n\tinput: CheckChainRevocationInput,\n\tsignerCtx: SignerValidationContext,\n): Promise<EvidenceEvaluation> {\n\tconst prefer = input.policy?.prefer ?? 'best-available';\n\tconst ocsp = await evaluateOcspEvidence(cert, issuer, input);\n\tconst crl = await evaluateCrlEvidence(cert, issuer, input, signerCtx);\n\tconst executionErrors = [...ocsp.executionErrors, ...crl.executionErrors];\n\n\t// 'best-available' ranks by evidence freshness; the sort is stable, so\n\t// equal (or absent) thisUpdate keeps OCSP first.\n\tconst ordered =\n\t\tprefer === 'crl'\n\t\t\t? [crl, ocsp]\n\t\t\t: prefer === 'ocsp'\n\t\t\t\t? [ocsp, crl]\n\t\t\t\t: [ocsp, crl].sort(\n\t\t\t\t\t\t(a, b) =>\n\t\t\t\t\t\t\t(b.status.source?.thisUpdate?.getTime() ?? 0) -\n\t\t\t\t\t\t\t(a.status.source?.thisUpdate?.getTime() ?? 0),\n\t\t\t\t\t);\n\tconst revoked = ordered.find((evaluation) => evaluation.status.status === 'revoked');\n\tif (revoked !== undefined) {\n\t\treturn { status: revoked.status, executionErrors };\n\t}\n\tconst good = ordered.find((evaluation) => evaluation.status.status === 'good');\n\tif (good !== undefined) {\n\t\treturn { status: good.status, executionErrors };\n\t}\n\n\tconst reasons = new Set<RevocationIndeterminateReason>();\n\tfor (const evaluation of ordered) {\n\t\tfor (const reason of evaluation.status.indeterminateReasons ?? []) {\n\t\t\treasons.add(reason);\n\t\t}\n\t}\n\treturn {\n\t\tstatus: {\n\t\t\tcertificate: cert,\n\t\t\tstatus: 'indeterminate',\n\t\t\tindeterminateReasons: [...reasons],\n\t\t},\n\t\texecutionErrors,\n\t};\n}\n\n// Function\n\n/**\n * Checks revocation status for all certificates in a validated chain.\n *\n * Evaluates CRL and OCSP evidence against each certificate (except the trust\n * anchor), applies the revocation policy, and returns a unified decision.\n *\n * @example\n * ```ts\n * const result = await checkChainRevocation({\n * chain: validatedChain,\n * crls: [crl1, crl2],\n * ocspResponses: [ocspResponseDer],\n * policy: { mode: 'hard-fail' },\n * });\n * if (result.value.decision === 'deny') {\n * console.log('Revocation check failed');\n * }\n * ```\n */\nexport async function checkChainRevocation(\n\tinput: CheckChainRevocationInput,\n): Promise<CheckChainRevocationResult> {\n\tconst { chain, policy, crls = [], extraCertificates = [], at = new Date() } = input;\n\tconst mode = policy?.mode ?? 'hard-fail';\n\n\t// Empty chain → allow\n\tif (chain.length === 0) {\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: {\n\t\t\t\tdecision: 'allow',\n\t\t\t\tsummary: { revokedCertificates: [], indeterminateCertificates: [] },\n\t\t\t\tcertificates: [],\n\t\t\t},\n\t\t};\n\t}\n\n\t// Create signer validation context with memoization cache\n\t// This cache is shared across all certificate checks in this chain evaluation\n\tconst signerCtx: SignerValidationContext = {\n\t\tcache: new Map(),\n\t\tchain,\n\t\tcrls,\n\t\textraCertificates,\n\t\tat,\n\t};\n\n\t// Skip trust anchor (last cert) — it's the trust base\n\tconst certsToCheck = chain.slice(0, -1);\n\tconst certificates: CertificateRevocationStatus[] = [];\n\tconst revokedCertificates: ParsedCertificate[] = [];\n\tconst indeterminateCertificates: ParsedCertificate[] = [];\n\tconst allExecutionErrors: RevocationExecutionError[] = [];\n\n\tfor (let i = 0; i < certsToCheck.length; i++) {\n\t\tconst cert = certsToCheck[i];\n\t\tconst issuer = chain[i + 1]; // Next cert in chain is the issuer\n\t\tif (cert === undefined || issuer === undefined) {\n\t\t\tcontinue; // Should never happen given loop bounds\n\t\t}\n\n\t\tconst { status, executionErrors } = await evaluateCertificateRevocation(\n\t\t\tcert,\n\t\t\tissuer,\n\t\t\tinput,\n\t\t\tsignerCtx,\n\t\t);\n\t\tcertificates.push(status);\n\t\tallExecutionErrors.push(...executionErrors);\n\n\t\tif (status.status === 'revoked') {\n\t\t\trevokedCertificates.push(cert);\n\t\t} else if (status.status === 'indeterminate') {\n\t\t\tindeterminateCertificates.push(cert);\n\t\t}\n\t}\n\n\t// Apply policy\n\tconst hasRevoked = revokedCertificates.length > 0;\n\tconst hasIndeterminate = indeterminateCertificates.length > 0;\n\tconst decision: 'allow' | 'deny' = hasRevoked\n\t\t? 'deny'\n\t\t: hasIndeterminate && mode === 'hard-fail'\n\t\t\t? 'deny'\n\t\t\t: 'allow';\n\n\treturn {\n\t\tok: true,\n\t\tvalue: {\n\t\t\tdecision,\n\t\t\tsummary: { revokedCertificates, indeterminateCertificates },\n\t\t\tcertificates,\n\t\t\t...(allExecutionErrors.length > 0 ? { executionErrors: allExecutionErrors } : {}),\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+HA,MAAa,IAAmC;CAE/C;CACA;CAEA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CAEA;AACD;;;;AAoIA,SAAS,mBAAmB,GAAoD;CAO/E,OANI,OAAO,KAAW,YAAY,YAAY,IACtC,IAEJ,OAAO,KAAW,WACd,EAAyC,CAAM,IAEhD,EAAyC,CAAM;AACvD;;;;AAKA,SAAS,qBAAqB,GAAoE;CACjG,IAAI;EACH,OAAO,EAA2B,CAAM;CACzC,QAAQ;EACP;CACD;AACD;;;;;AAMA,SAAS,gBAAgB,GAAsB,GAA+B;CAC7E,IAAI,EAAE,IAAI,WAAW,EAAE,IAAI,QAAQ,OAAO;CAC1C,KAAK,IAAI,IAAI,GAAG,IAAI,EAAE,IAAI,QAAQ,KACjC,IAAI,EAAE,IAAI,OAAO,EAAE,IAAI,IAAI,OAAO;CAEnC,OAAO;AACR;;;;;;;AAQA,SAAS,uBACR,GACA,GACA,GAC+B;CAC/B,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AAsB,qBACrB,GACsC;CACtC,IAAM,EAAE,UAAO,WAAQ,UAAO,CAAC,GAAG,uBAAoB,CAAC,GAAG,wBAAK,IAAI,KAAK,MAAM,GACxE,IAAO,GAAQ,QAAQ;CAG7B,IAAI,EAAM,WAAW,GACpB,OAAO;EACN,IAAI;EACJ,OAAO;GACN,UAAU;GACV,SAAS;IAAE,qBAAqB,CAAC;IAAG,2BAA2B,CAAC;GAAE;GAClE,cAAc,CAAC;EAChB;CACD;CAKD,IAAM,IAAqC;EAC1C,uBAAO,IAAI,IAAI;EACf;EACA;EACA;EACA;CACD,GAGM,IAAe,EAAM,MAAM,GAAG,EAAE,GAChC,IAA8C,CAAC,GAC/C,IAA2C,CAAC,GAC5C,IAAiD,CAAC,GAClD,IAAiD,CAAC;CAExD,KAAK,IAAI,IAAI,GAAG,IAAI,EAAa,QAAQ,KAAK;EAC7C,IAAM,IAAO,EAAa,IACpB,IAAS,EAAM,IAAI;EACzB,IAAI,MAAS,KAAA,KAAa,MAAW,KAAA,GACpC;EAGD,IAAM,EAAE,WAAQ,uBAAoB,MAAM,8BACzC,GACA,GACA,GACA,CACD;EAIA,AAHA,EAAa,KAAK,CAAM,GACxB,EAAmB,KAAK,GAAG,CAAe,GAEtC,EAAO,WAAW,YACrB,EAAoB,KAAK,CAAI,IACnB,EAAO,WAAW,mBAC5B,EAA0B,KAAK,CAAI;CAErC;CAGA,IAAM,IAAa,EAAoB,SAAS,GAC1C,IAAmB,EAA0B,SAAS;CAO5D,OAAO;EACN,IAAI;EACJ,OAAO;GACN,UATiC,KAEhC,KAAoB,MAAS,cAD7B,SAGC;GAMF,SAAS;IAAE;IAAqB;GAA0B;GAC1D;GACA,GAAI,EAAmB,SAAS,IAAI,EAAE,iBAAiB,EAAmB,IAAI,CAAC;EAChF;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"chain.js","names":["_exhaustive"],"sources":["../../src/revocation/chain.ts"],"sourcesContent":["/**\n * Chain-level revocation orchestration.\n *\n * Evaluates CRL and OCSP evidence for an entire validated certificate chain,\n * implementing the revocation checking portion of RFC 5280 §6.3.\n *\n * @see {@link https://datatracker.ietf.org/doc/html/rfc5280#section-6.3 | RFC 5280 §6.3 CRL Validation}\n * @module\n */\n\nimport type {\n\tCrlSource,\n\tParsedCertificateRevocationList,\n\tRevocationReason,\n} from '#micro509/revocation/crl';\nimport {\n\tcheckCertificateRevocationAgainstCrl,\n\tcoversAllDistributionPointReasons,\n\tparseCertificateRevocationListDerOrThrow,\n\tparseCertificateRevocationListPemOrThrow,\n\trevocationReasonFromCode,\n} from '#micro509/revocation/crl';\nimport type {\n\tOcspResponderRevocationPolicy,\n\tParsedOcspResponse,\n\tValidateOcspResponseFailure,\n\tValidateOcspResponseResult,\n} from '#micro509/revocation/ocsp';\nimport {\n\tparseOcspResponseDerOrThrow,\n\tparseOcspResponsePemOrThrow,\n\tvalidateOcspResponse,\n} from '#micro509/revocation/ocsp';\nimport type { RevocationCertificateSource } from '#micro509/revocation/revocation';\nimport { verifyCertificateChain } from '#micro509/verify/verify';\nimport type { DistributionPointReason } from '#micro509/x509/extensions';\nimport type { ParsedCertificate } from '#micro509/x509/parse';\nimport { parseCertificateFromSource } from '#micro509/x509/parse';\n\nexport type { CrlSource };\n\n// Input Types\n\n/**\n * OCSP response in any supported format.\n *\n * Accepts PEM string or DER bytes. Used for\n * {@linkcode CheckChainRevocationInput.ocspResponses}.\n */\nexport type OcspResponseSource = string | Uint8Array;\n\n/**\n * Revocation checking policy for {@linkcode checkChainRevocation}.\n *\n * Controls how indeterminate results (missing evidence, expired CRLs) affect\n * the final {@linkcode CheckChainRevocationValue.decision | decision}.\n */\nexport interface RevocationPolicy {\n\t/**\n\t * How to handle indeterminate status.\n\t *\n\t * - `'hard-fail'`: indeterminate certificates cause denial (default)\n\t * - `'soft-fail'`: indeterminate certificates are allowed — an explicit\n\t * availability/compatibility choice\n\t *\n\t * Revocation checking itself is opt-in: no check runs unless evidence is\n\t * supplied. Once it is, indeterminate status denies by default.\n\t */\n\treadonly mode?: 'soft-fail' | 'hard-fail';\n\t/**\n\t * Evidence preference when multiple sources are available.\n\t *\n\t * Both evidence kinds are always evaluated, and a validated `revoked`\n\t * verdict from either source wins regardless of preference (fail-closed).\n\t * Preference only decides which source's `good` verdict is reported when\n\t * both yield one.\n\t *\n\t * - `'best-available'`: the source with the fresher evidence — the later\n\t * `thisUpdate` on the validated OCSP entry or CRL — is reported; ties\n\t * favor OCSP (default)\n\t * - `'ocsp'`: prefer OCSP over CRL\n\t * - `'crl'`: prefer CRL over OCSP\n\t */\n\treadonly prefer?: 'ocsp' | 'crl' | 'best-available';\n\t/**\n\t * Revocation policy for delegated OCSP responder certificates\n\t * (RFC 6960 §4.2.2.2.1). Supplied CRLs double as responder revocation\n\t * evidence. Defaults to `'honor-nocheck'`.\n\t */\n\treadonly ocspResponderRevocation?: OcspResponderRevocationPolicy;\n}\n\n/** Input for {@linkcode checkChainRevocation}. */\nexport interface CheckChainRevocationInput {\n\t/** Validated certificate chain (leaf first, root last). */\n\treadonly chain: readonly ParsedCertificate[];\n\t/** CRLs to evaluate. */\n\treadonly crls?: readonly CrlSource[];\n\t/** OCSP responses to evaluate. */\n\treadonly ocspResponses?: readonly OcspResponseSource[];\n\t/** Extra certs for indirect CRL issuers / delegated OCSP responders. */\n\treadonly extraCertificates?: readonly RevocationCertificateSource[];\n\t/**\n\t * Explicitly trusted OCSP responder certificates (RFC 6960 §4.2.2.2\n\t * criterion 1). A response signed by one of these is accepted without\n\t * delegated-responder issuance, EKU, and revocation checks.\n\t */\n\treadonly trustedOcspResponders?: readonly RevocationCertificateSource[];\n\t/** Evaluation time. Defaults to `new Date()`. */\n\treadonly at?: Date;\n\t/** Revocation policy. */\n\treadonly policy?: RevocationPolicy;\n}\n\n// Output Types\n\n/**\n * Granular reasons why revocation status could not be determined.\n *\n * Returned in {@linkcode CertificateRevocationStatus}'s `indeterminateReasons`\n * when `status` is `'indeterminate'`. Grouped by category:\n *\n * - **Evidence not found**: `no_applicable_crl`, `no_applicable_ocsp`\n * - **Scope mismatch**: `distribution_point_mismatch`, `issuer_name_mismatch`,\n * `reason_scope_mismatch`, `indirect_crl_scope_mismatch`, `reason_coverage_incomplete`\n * - **Signer trust**: `crl_signer_not_found`, `crl_signer_not_authorized`,\n * `crl_signer_revoked`, `crl_signer_indeterminate`, and OCSP equivalents\n * - **Freshness**: `crl_expired`, `ocsp_response_expired`\n */\nexport const REVOCATION_INDETERMINATE_REASONS = [\n\t// Evidence not found\n\t'no_applicable_crl',\n\t'no_applicable_ocsp',\n\t// Scope issues\n\t'distribution_point_mismatch',\n\t'issuer_name_mismatch',\n\t'reason_scope_mismatch',\n\t'indirect_crl_scope_mismatch',\n\t'reason_coverage_incomplete',\n\t// Signer trust issues\n\t'crl_signer_not_found',\n\t'crl_signer_not_authorized',\n\t'crl_signer_revoked',\n\t'crl_signer_indeterminate',\n\t'ocsp_responder_not_found',\n\t'ocsp_responder_not_authorized',\n\t'ocsp_responder_revoked',\n\t'ocsp_responder_indeterminate',\n\t// Freshness\n\t'crl_expired',\n\t'ocsp_response_expired',\n\t// OCSP specific\n\t'ocsp_status_unknown',\n] as const;\n\n/** See the doc comment above {@linkcode REVOCATION_INDETERMINATE_REASONS}. */\nexport type RevocationIndeterminateReason = (typeof REVOCATION_INDETERMINATE_REASONS)[number];\n\n/**\n * Identifies the source of revocation evidence.\n *\n * Included in {@linkcode CertificateRevocationStatus}'s `source` when status is\n * `'good'` or `'revoked'` to indicate which CRL or OCSP response provided the answer.\n */\nexport interface RevocationSource {\n\t/** Whether evidence came from a CRL or OCSP response. */\n\treadonly kind: 'crl' | 'ocsp';\n\t/** Certificate that signed the evidence (CRL issuer or OCSP responder). */\n\treadonly signerCertificate?: ParsedCertificate;\n\t/** Identifier for debugging (e.g., CRL issuer DN or OCSP responder URL). */\n\treadonly evidenceIdentifier?: string;\n\t/**\n\t * `thisUpdate` of the evidence backing the verdict — the OCSP single\n\t * response entry or the freshest contributing CRL (an applied delta CRL\n\t * supersedes its base). This is the timestamp `'best-available'` compares.\n\t */\n\treadonly thisUpdate?: Date;\n}\n\n/**\n * Revocation evaluation result for a single certificate.\n *\n * One entry per certificate in {@linkcode CheckChainRevocationValue.certificates}.\n * The trust anchor is excluded (never checked for revocation).\n */\nexport type CertificateRevocationStatus =\n\t| {\n\t\t\t/** The certificate that was evaluated. */\n\t\t\treadonly certificate: ParsedCertificate;\n\t\t\t/** Evidence confirms the certificate is not revoked. */\n\t\t\treadonly status: 'good';\n\t\t\t/** Evidence that produced the verdict. */\n\t\t\treadonly source: RevocationSource;\n\t\t\t/** Never present on a `good` verdict. */\n\t\t\treadonly indeterminateReasons?: undefined;\n\t\t\t/** Never present on a `good` verdict. */\n\t\t\treadonly revocationInfo?: undefined;\n\t }\n\t| {\n\t\t\t/** The certificate that was evaluated. */\n\t\t\treadonly certificate: ParsedCertificate;\n\t\t\t/** Evidence confirms the certificate is revoked. */\n\t\t\treadonly status: 'revoked';\n\t\t\t/** Evidence that produced the verdict. */\n\t\t\treadonly source: RevocationSource;\n\t\t\t/** Revocation details from the CRL entry or OCSP response. */\n\t\t\treadonly revocationInfo: {\n\t\t\t\t/** When the certificate was revoked. */\n\t\t\t\treadonly revocationDate: Date;\n\t\t\t\t/** RFC 5280 CRLReason code, if provided by the CRL/OCSP response. */\n\t\t\t\treadonly reason?: RevocationReason;\n\t\t\t};\n\t\t\t/** Never present on a `revoked` verdict. */\n\t\t\treadonly indeterminateReasons?: undefined;\n\t }\n\t| {\n\t\t\t/** The certificate that was evaluated. */\n\t\t\treadonly certificate: ParsedCertificate;\n\t\t\t/** Revocation status could not be determined. */\n\t\t\treadonly status: 'indeterminate';\n\t\t\t/** Why status could not be determined. */\n\t\t\treadonly indeterminateReasons: readonly RevocationIndeterminateReason[];\n\t\t\t/** Never present on an `indeterminate` verdict. */\n\t\t\treadonly source?: undefined;\n\t\t\t/** Never present on an `indeterminate` verdict. */\n\t\t\treadonly revocationInfo?: undefined;\n\t };\n\n/**\n * Errors encountered while processing revocation evidence.\n *\n * Distinct from {@linkcode RevocationIndeterminateReason}: execution errors are\n * code failures (malformed CRL, unsupported extension) rather than evaluation\n * outcomes (CRL doesn't cover this certificate).\n *\n * Collected in {@linkcode CheckChainRevocationValue.executionErrors}.\n */\nexport interface RevocationExecutionError {\n\t/** Error category. */\n\treadonly kind: 'parse_error' | 'unsupported_extension' | 'internal_error';\n\t/** Human-readable error description. */\n\treadonly message: string;\n\t/** Which evidence caused the error (e.g., CRL issuer DN). */\n\treadonly evidenceIdentifier?: string;\n}\n\n/**\n * Detailed revocation check results.\n *\n * Returned as {@linkcode CheckChainRevocationResult.value} from\n * {@linkcode checkChainRevocation}. Contains both the policy decision and\n * detailed per-certificate findings for debugging.\n */\nexport interface CheckChainRevocationValue {\n\t/**\n\t * Final policy decision based on {@linkcode RevocationPolicy}.\n\t *\n\t * - `'allow'`: chain passes revocation check\n\t * - `'deny'`: chain fails (revoked certificate or hard-fail on indeterminate)\n\t */\n\treadonly decision: 'allow' | 'deny';\n\t/** Quick-access summary of problematic certificates. */\n\treadonly summary: {\n\t\t/** Certificates confirmed as revoked. */\n\t\treadonly revokedCertificates: readonly ParsedCertificate[];\n\t\t/** Certificates whose status could not be determined. */\n\t\treadonly indeterminateCertificates: readonly ParsedCertificate[];\n\t};\n\t/** Per-certificate evaluation results. See {@linkcode CertificateRevocationStatus}. */\n\treadonly certificates: readonly CertificateRevocationStatus[];\n\t/** Evidence that could not be processed. See {@linkcode RevocationExecutionError}. */\n\treadonly executionErrors?: readonly RevocationExecutionError[];\n}\n\n/** Result type for {@linkcode checkChainRevocation}. */\nexport type CheckChainRevocationResult = {\n\treadonly ok: true;\n\treadonly value: CheckChainRevocationValue;\n};\n\n// Helpers\n\n/**\n * Parses a CRL from various source formats.\n */\nfunction parseCrlFromSource(source: CrlSource): ParsedCertificateRevocationList {\n\tif (typeof source === 'object' && 'issuer' in source) {\n\t\treturn source;\n\t}\n\tif (typeof source === 'string') {\n\t\treturn parseCertificateRevocationListPemOrThrow(source);\n\t}\n\treturn parseCertificateRevocationListDerOrThrow(source);\n}\n\n/**\n * Parses a certificate from various source formats, returning undefined on failure.\n */\nfunction parseCertificateSafe(source: RevocationCertificateSource): ParsedCertificate | undefined {\n\ttry {\n\t\treturn parseCertificateFromSource(source);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Compares two certificates by DER bytes for identity.\n * Reference equality fails when same cert is parsed from different sources.\n */\nfunction sameCertificate(a: ParsedCertificate, b: ParsedCertificate): boolean {\n\tif (a.der.length !== b.der.length) return false;\n\tfor (let i = 0; i < a.der.length; i++) {\n\t\tif (a.der[i] !== b.der[i]) return false;\n\t}\n\treturn true;\n}\n\n/**\n * Yields every certificate that could have signed the given CRL, AKI/SKI\n * matches before DN matches. All candidates are returned so a certificate whose\n * subject DN collides with the genuine CRL issuer cannot shadow it: each is\n * tried against the CRL signature and its own path to the trust anchor.\n */\nfunction findIndirectCrlIssuers(\n\tcrl: ParsedCertificateRevocationList,\n\textraCertificates: readonly RevocationCertificateSource[],\n\tchain: readonly ParsedCertificate[],\n): readonly ParsedCertificate[] {\n\tconst parsedExtras: ParsedCertificate[] = [];\n\tfor (const source of extraCertificates) {\n\t\tconst parsed = parseCertificateSafe(source);\n\t\tif (parsed !== undefined) {\n\t\t\tparsedExtras.push(parsed);\n\t\t}\n\t}\n\n\tconst candidates = [...parsedExtras, ...chain];\n\tconst matches: ParsedCertificate[] = [];\n\tconst push = (candidate: ParsedCertificate): void => {\n\t\tif (!matches.some((existing) => sameCertificate(existing, candidate))) {\n\t\t\tmatches.push(candidate);\n\t\t}\n\t};\n\n\tif (crl.authorityKeyIdentifier !== undefined) {\n\t\tfor (const candidate of candidates) {\n\t\t\tif (\n\t\t\t\tcandidate.subjectKeyIdentifier !== undefined &&\n\t\t\t\tnormalizeHex(crl.authorityKeyIdentifier) === normalizeHex(candidate.subjectKeyIdentifier)\n\t\t\t) {\n\t\t\t\tpush(candidate);\n\t\t\t}\n\t\t}\n\t}\n\tfor (const candidate of candidates) {\n\t\tif (crl.issuer.derHex === candidate.subject.derHex) {\n\t\t\tpush(candidate);\n\t\t}\n\t}\n\n\treturn matches;\n}\n\n/** Lowercases a hex string for bytewise comparison. */\nfunction normalizeHex(value: string): string {\n\treturn value.toLowerCase();\n}\n\n/**\n * RFC 5280 §6.3.3(f): confirms the CRL issuer certificate has a valid\n * certification path to the same trust anchor as the certificate under test. A\n * signer already inside the validated chain is authorized by construction. The\n * path check runs without revocation to avoid unbounded recursion.\n */\nasync function crlSignerChainsToAnchor(\n\tsigner: ParsedCertificate,\n\tchain: readonly ParsedCertificate[],\n\textraCertificates: readonly RevocationCertificateSource[],\n\tat: Date,\n): Promise<boolean> {\n\tif (chain.some((c) => sameCertificate(c, signer))) {\n\t\treturn true;\n\t}\n\tconst trustAnchor = chain[chain.length - 1];\n\tif (trustAnchor === undefined) {\n\t\treturn false;\n\t}\n\t// The signer's issuer may be a validated chain certificate (a delegated\n\t// signer issued by an intermediate), so pool the non-anchor chain members\n\t// with the extras. Exclude the signer and the anchor.\n\tconst pool: ParsedCertificate[] = [];\n\tconst addCandidate = (parsed: ParsedCertificate): void => {\n\t\tif (sameCertificate(parsed, signer) || sameCertificate(parsed, trustAnchor)) {\n\t\t\treturn;\n\t\t}\n\t\tif (!pool.some((existing) => sameCertificate(existing, parsed))) {\n\t\t\tpool.push(parsed);\n\t\t}\n\t};\n\tfor (let index = 0; index < chain.length - 1; index += 1) {\n\t\tconst certificate = chain[index];\n\t\tif (certificate !== undefined) {\n\t\t\taddCandidate(certificate);\n\t\t}\n\t}\n\tfor (const source of extraCertificates) {\n\t\tconst parsed = parseCertificateSafe(source);\n\t\tif (parsed !== undefined) {\n\t\t\taddCandidate(parsed);\n\t\t}\n\t}\n\tconst result = await verifyCertificateChain({\n\t\tleaf: signer.der,\n\t\tintermediates: pool.map((certificate) => certificate.der),\n\t\troots: [trustAnchor.der],\n\t\tat,\n\t});\n\treturn result.ok;\n}\n\n// CRL Signer Validation (RFC 5280 §6.3.3)\n\n/**\n * State machine for CRL signer validation with memoization.\n * - `visiting`: Currently being checked (cycle detection)\n * - `resolved-valid`: Signer is not revoked\n * - `resolved-revoked`: Signer is revoked\n * - `resolved-indeterminate`: Can't determine signer status\n */\ntype SignerValidationState =\n\t| 'visiting'\n\t| 'resolved-valid'\n\t| 'resolved-revoked'\n\t| 'resolved-indeterminate';\n\n/** Context for CRL signer validation with memoization cache. */\ninterface SignerValidationContext {\n\treadonly cache: Map<string, SignerValidationState>;\n\treadonly chain: readonly ParsedCertificate[];\n\treadonly crls: readonly CrlSource[];\n\treadonly extraCertificates: readonly RevocationCertificateSource[];\n\treadonly at: Date;\n}\n\n/**\n * Builds a unique cache key for a certificate.\n * Uses issuer DN + serial number which uniquely identifies a cert.\n */\nfunction certCacheKey(cert: ParsedCertificate): string {\n\treturn `${cert.issuer.derHex}:${cert.serialNumberHex}`;\n}\n\n/**\n * Validates that a CRL signer certificate is not revoked.\n * Uses memoization to avoid redundant checks and detect cycles.\n */\nasync function validateCrlSigner(\n\tsigner: ParsedCertificate,\n\tctx: SignerValidationContext,\n): Promise<SignerValidationState> {\n\t// Use issuer+serial as cache key (unique per certificate)\n\tconst key = certCacheKey(signer);\n\tconst cached = ctx.cache.get(key);\n\n\t// Cycle detection: if we're already visiting this signer, it's indeterminate\n\tif (cached === 'visiting') {\n\t\treturn 'resolved-indeterminate';\n\t}\n\n\t// Return cached result if already resolved\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\t// Mark as visiting before recursive checks\n\tctx.cache.set(key, 'visiting');\n\n\t// Trust anchor (last in chain) is trusted by definition\n\tconst trustAnchor = ctx.chain[ctx.chain.length - 1];\n\tif (trustAnchor !== undefined && sameCertificate(signer, trustAnchor)) {\n\t\tctx.cache.set(key, 'resolved-valid');\n\t\treturn 'resolved-valid';\n\t}\n\n\t// If signer is in the validated chain, it's trusted\n\t// (Chain was already validated before revocation checking)\n\tconst isInChain = ctx.chain.some((c) => sameCertificate(c, signer));\n\tif (isInChain) {\n\t\tctx.cache.set(key, 'resolved-valid');\n\t\treturn 'resolved-valid';\n\t}\n\n\t// Signer is not in chain — need to check its revocation status\n\t// Find signer's issuer to perform revocation check\n\tconst signerIssuer = findSignerIssuer(signer, ctx);\n\tif (signerIssuer === undefined) {\n\t\tctx.cache.set(key, 'resolved-indeterminate');\n\t\treturn 'resolved-indeterminate';\n\t}\n\n\t// Check signer's revocation status (recursive)\n\tconst signerRevocation = await checkSignerRevocation(signer, signerIssuer, ctx);\n\tctx.cache.set(key, signerRevocation);\n\treturn signerRevocation;\n}\n\n/**\n * Finds the issuer certificate for a CRL signer.\n * Searches the chain and extraCertificates by AKI/SKI or DN matching.\n */\nfunction findSignerIssuer(\n\tsigner: ParsedCertificate,\n\tctx: SignerValidationContext,\n): ParsedCertificate | undefined {\n\t// Parse extra certificates\n\tconst parsedExtras: ParsedCertificate[] = [];\n\tfor (const source of ctx.extraCertificates) {\n\t\tconst parsed = parseCertificateSafe(source);\n\t\tif (parsed !== undefined) {\n\t\t\tparsedExtras.push(parsed);\n\t\t}\n\t}\n\n\tconst candidates = [...ctx.chain, ...parsedExtras];\n\n\tfor (const candidate of candidates) {\n\t\t// Match by AKI → SKI (preferred, more specific)\n\t\tif (\n\t\t\tsigner.authorityKeyIdentifier !== undefined &&\n\t\t\tcandidate.subjectKeyIdentifier !== undefined &&\n\t\t\tnormalizeHex(signer.authorityKeyIdentifier) === normalizeHex(candidate.subjectKeyIdentifier)\n\t\t) {\n\t\t\treturn candidate;\n\t\t}\n\n\t\t// Match by issuer DN → subject DN\n\t\tif (signer.issuer.derHex === candidate.subject.derHex) {\n\t\t\treturn candidate;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Checks if a CRL signer certificate is revoked by examining available CRLs.\n * Recursively validates the CRL signer of any CRL used to check revocation.\n */\nasync function checkSignerRevocation(\n\tsigner: ParsedCertificate,\n\tissuer: ParsedCertificate,\n\tctx: SignerValidationContext,\n): Promise<SignerValidationState> {\n\t// If the signer's issuer is in the validated chain, the signer is trusted\n\t// by virtue of being issued by a trusted CA. We only need to check if\n\t// it's explicitly revoked, not prove \"good\" status.\n\tconst issuerInChain = ctx.chain.some((c) => sameCertificate(c, issuer));\n\n\t// A `good` from one CRL does not end the search: a later CRL may report the\n\t// signer revoked, and a revoked verdict from any CRL wins.\n\tconst coveredReasons = new Set<string>();\n\tfor (const crlSource of ctx.crls) {\n\t\tconst outcome = await checkSignerAgainstCrl(signer, issuer, crlSource, ctx);\n\t\tif (outcome.kind === 'revoked') {\n\t\t\treturn 'resolved-revoked';\n\t\t}\n\t\tfor (const reason of outcome.reasons) {\n\t\t\tcoveredReasons.add(reason);\n\t\t}\n\t}\n\tif (coversAllDistributionPointReasons(coveredReasons)) {\n\t\treturn 'resolved-valid';\n\t}\n\n\t// If the signer's issuer is in the chain and we found no revocation,\n\t// trust the signer (issued by trusted CA, no evidence of revocation)\n\tif (issuerInChain) {\n\t\treturn 'resolved-valid';\n\t}\n\n\treturn 'resolved-indeterminate';\n}\n\n/** What one CRL settles about a signer: a revoked verdict, or the reasons it covers. */\ntype SignerCrlOutcome =\n\t| { readonly kind: 'revoked' }\n\t| { readonly kind: 'reasons'; readonly reasons: readonly DistributionPointReason[] };\n\nconst SIGNER_CRL_NO_EVIDENCE = {\n\tkind: 'reasons',\n\treasons: [],\n} as const satisfies SignerCrlOutcome;\n\n/**\n * Evaluates one CRL against a signer. A CRL that does not parse, does not\n * apply, or is itself signed by a signer that is not known good yields no\n * evidence rather than a verdict.\n */\nasync function checkSignerAgainstCrl(\n\tsigner: ParsedCertificate,\n\tissuer: ParsedCertificate,\n\tcrlSource: CrlSource,\n\tctx: SignerValidationContext,\n): Promise<SignerCrlOutcome> {\n\tlet crl: ParsedCertificateRevocationList;\n\ttry {\n\t\tcrl = parseCrlFromSource(crlSource);\n\t} catch {\n\t\treturn SIGNER_CRL_NO_EVIDENCE;\n\t}\n\tconst result = await checkCertificateRevocationAgainstCrl({\n\t\tcertificate: signer,\n\t\tissuerCertificate: issuer,\n\t\tcrl,\n\t\tat: ctx.at,\n\t});\n\tif (!result.ok) {\n\t\treturn SIGNER_CRL_NO_EVIDENCE;\n\t}\n\tif (result.value.status === 'revoked') {\n\t\treturn { kind: 'revoked' };\n\t}\n\t// The CRL's signer is the issuer just used, and it must itself be good.\n\treturn (await validateCrlSigner(issuer, ctx)) === 'resolved-valid'\n\t\t? { kind: 'reasons', reasons: result.value.coveredReasons }\n\t\t: SIGNER_CRL_NO_EVIDENCE;\n}\n\n/** Builds the `revoked` CertificateRevocationStatus for a CRL hit. */\nfunction buildCrlRevokedStatus(\n\tcert: ParsedCertificate,\n\tsigner: ParsedCertificate,\n\tthisUpdate: Date,\n\trevocationDate: Date,\n\treasonCode?: RevocationReason,\n): CertificateRevocationStatus {\n\treturn {\n\t\tcertificate: cert,\n\t\tstatus: 'revoked',\n\t\tsource: { kind: 'crl', signerCertificate: signer, thisUpdate },\n\t\trevocationInfo: {\n\t\t\trevocationDate,\n\t\t\t...(reasonCode !== undefined ? { reason: reasonCode } : {}),\n\t\t},\n\t};\n}\n\n// OCSP Evidence Evaluation (RFC 6960)\n\n/** Per-certificate evidence evaluation outcome shared by the CRL and OCSP evaluators. */\ninterface EvidenceEvaluation {\n\treadonly status: CertificateRevocationStatus;\n\treadonly executionErrors: readonly RevocationExecutionError[];\n}\n\n/** Parses an OCSP response from PEM string or DER bytes. */\nfunction parseOcspResponseFromSource(source: OcspResponseSource): ParsedOcspResponse {\n\tif (typeof source === 'string') {\n\t\treturn parseOcspResponsePemOrThrow(source);\n\t}\n\treturn parseOcspResponseDerOrThrow(source);\n}\n\n/** Maps a {@linkcode validateOcspResponse} failure code to an indeterminate reason. */\nfunction ocspIndeterminateReasonFromFailure(\n\tcode: ValidateOcspResponseFailure['code'],\n): RevocationIndeterminateReason {\n\tswitch (code) {\n\t\tcase 'stale_response':\n\t\t\treturn 'ocsp_response_expired';\n\t\tcase 'responder_id_mismatch':\n\t\tcase 'responder_chain_invalid':\n\t\tcase 'ocsp_signing_missing':\n\t\t\treturn 'ocsp_responder_not_authorized';\n\t\tcase 'responder_revoked':\n\t\t\treturn 'ocsp_responder_revoked';\n\t\tcase 'signature_invalid':\n\t\tcase 'responder_revocation_unknown':\n\t\t\treturn 'ocsp_responder_indeterminate';\n\t\tcase 'response_status_invalid':\n\t\tcase 'issuer_mismatch':\n\t\tcase 'nonce_mismatch':\n\t\tcase 'request_mismatch':\n\t\t\treturn 'no_applicable_ocsp';\n\t\tdefault: {\n\t\t\tconst _exhaustive: never = code;\n\t\t\tthrow new Error(`Unhandled ValidateOcspResponse failure code: ${String(_exhaustive)}`);\n\t\t}\n\t}\n}\n\n/** Validation failures worth retrying with an explicit responder certificate. */\nconst OCSP_RESPONDER_FAILURE_CODES: ReadonlySet<ValidateOcspResponseFailure['code']> = new Set([\n\t'signature_invalid',\n\t'responder_id_mismatch',\n\t'responder_chain_invalid',\n\t'ocsp_signing_missing',\n]);\n\n/**\n * Validates an OCSP response, retrying with caller-provided extra certificates\n * as explicit responder certificates when embedded discovery fails.\n */\nasync function validateOcspResponseWithResponderFallback(\n\tresponse: ParsedOcspResponse,\n\tissuer: ParsedCertificate,\n\tinput: CheckChainRevocationInput,\n\tat: Date,\n): Promise<ValidateOcspResponseResult> {\n\tconst shared = {\n\t\tissuerCertificate: issuer,\n\t\tat,\n\t\t...(input.trustedOcspResponders !== undefined\n\t\t\t? { trustedOcspResponders: input.trustedOcspResponders }\n\t\t\t: {}),\n\t\t...(input.policy?.ocspResponderRevocation !== undefined\n\t\t\t? { responderRevocationPolicy: input.policy.ocspResponderRevocation }\n\t\t\t: {}),\n\t\t// Chain-level CRLs double as responder revocation evidence\n\t\t...(input.crls !== undefined ? { responderRevocationCrls: input.crls } : {}),\n\t};\n\tconst primary = await validateOcspResponse({ response, ...shared });\n\tif (primary.ok || !OCSP_RESPONDER_FAILURE_CODES.has(primary.code)) {\n\t\treturn primary;\n\t}\n\tfor (const source of input.extraCertificates ?? []) {\n\t\tconst responder = parseCertificateSafe(source);\n\t\tif (responder === undefined) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst retry = await validateOcspResponse({\n\t\t\tresponse,\n\t\t\t...shared,\n\t\t\tresponderCertificate: responder,\n\t\t});\n\t\tif (retry.ok) {\n\t\t\treturn retry;\n\t\t}\n\t}\n\treturn primary;\n}\n\n/**\n * Evaluates OCSP evidence for a single certificate (RFC 6960).\n *\n * Every response is fully validated — signature, responder binding and\n * authorization, and freshness — via {@linkcode validateOcspResponse} before\n * its status entry is trusted. Issuer binding of each CertID is enforced by\n * the validator, so a serial-number match on a validated response is\n * sufficient to attribute the entry to `cert`.\n */\nasync function evaluateOcspEvidence(\n\tcert: ParsedCertificate,\n\tissuer: ParsedCertificate,\n\tinput: CheckChainRevocationInput,\n): Promise<EvidenceEvaluation> {\n\tconst { ocspResponses = [], at = new Date() } = input;\n\tconst executionErrors: RevocationExecutionError[] = [];\n\tconst reasons = new Set<RevocationIndeterminateReason>();\n\n\tfor (const source of ocspResponses) {\n\t\tlet parsed: ParsedOcspResponse;\n\t\ttry {\n\t\t\tparsed = parseOcspResponseFromSource(source);\n\t\t} catch (e) {\n\t\t\texecutionErrors.push({\n\t\t\t\tkind: 'parse_error',\n\t\t\t\tmessage: e instanceof Error ? e.message : 'OCSP response parse failed',\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst entry = (parsed.responses ?? []).find(\n\t\t\t(single) =>\n\t\t\t\tnormalizeHex(single.certId.serialNumberHex) === normalizeHex(cert.serialNumberHex),\n\t\t);\n\t\tif (entry === undefined) {\n\t\t\tcontinue; // Response does not cover this certificate\n\t\t}\n\n\t\tconst validation = await validateOcspResponseWithResponderFallback(parsed, issuer, input, at);\n\t\tif (!validation.ok) {\n\t\t\treasons.add(ocspIndeterminateReasonFromFailure(validation.code));\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (entry.certStatus === 'revoked') {\n\t\t\tconst reason = revocationReasonFromCode(entry.revocationReasonCode);\n\t\t\treturn {\n\t\t\t\tstatus: {\n\t\t\t\t\tcertificate: cert,\n\t\t\t\t\tstatus: 'revoked',\n\t\t\t\t\tsource: { kind: 'ocsp', thisUpdate: entry.thisUpdate },\n\t\t\t\t\trevocationInfo: {\n\t\t\t\t\t\trevocationDate: entry.revokedAt ?? entry.thisUpdate,\n\t\t\t\t\t\t...(reason !== undefined ? { reason } : {}),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\texecutionErrors,\n\t\t\t};\n\t\t}\n\t\tif (entry.certStatus === 'good') {\n\t\t\treturn {\n\t\t\t\tstatus: {\n\t\t\t\t\tcertificate: cert,\n\t\t\t\t\tstatus: 'good',\n\t\t\t\t\tsource: { kind: 'ocsp', thisUpdate: entry.thisUpdate },\n\t\t\t\t},\n\t\t\t\texecutionErrors,\n\t\t\t};\n\t\t}\n\t\treasons.add('ocsp_status_unknown');\n\t}\n\n\tif (reasons.size === 0) {\n\t\treasons.add('no_applicable_ocsp');\n\t}\n\treturn {\n\t\tstatus: {\n\t\t\tcertificate: cert,\n\t\t\tstatus: 'indeterminate',\n\t\t\tindeterminateReasons: [...reasons],\n\t\t},\n\t\texecutionErrors,\n\t};\n}\n\n/**\n * Evaluates revocation status for a single certificate using available CRLs.\n * Returns both status and any execution errors encountered.\n *\n * Tries the chain issuer first; if that fails, searches extraCertificates\n * and chain for an indirect CRL issuer that matches the CRL's AKI or issuer DN.\n *\n * Also validates that CRL signers are not revoked (RFC 5280 §6.3.3).\n */\n// RFC 5280 ReasonFlags — all possible revocation reasons that CRLs can cover.\ninterface CrlEvidenceState {\n\treadonly executionErrors: RevocationExecutionError[];\n\treadonly coveredReasons: Set<string>;\n\tsawCrlSignerRevoked: boolean;\n\tsawCrlSignerIndeterminate: boolean;\n\tsawCrlSignerNotAuthorized: boolean;\n\tsawGood: boolean;\n\tfreshestGood?: { readonly signer: ParsedCertificate; readonly thisUpdate: Date };\n}\n\n/** Inputs for resolving one base CRL against its candidate signers. */\ninterface BaseCrlResolution {\n\treadonly cert: ParsedCertificate;\n\treadonly baseCrl: ParsedCertificateRevocationList;\n\treadonly applicableDelta: ParsedCertificateRevocationList | undefined;\n\treadonly crlThisUpdate: Date;\n\treadonly issuer: ParsedCertificate;\n\treadonly extraCertificates: readonly RevocationCertificateSource[];\n\treadonly chain: readonly ParsedCertificate[];\n\treadonly at: Date;\n\treadonly signerCtx: SignerValidationContext;\n\treadonly state: CrlEvidenceState;\n}\n\n/**\n * Runs each candidate signer through the full pipeline for one base CRL:\n * signature/applicability, RFC 5280 §6.3.3(f) path to the anchor, then signer\n * revocation. A candidate that verifies the signature but fails a later step\n * does not shadow a subsequent usable signer, so the search continues. Returns\n * a revoked status when one is found; otherwise records good or diagnostic\n * evidence into `state`.\n */\nasync function resolveBaseCrlAgainstSigners(\n\tparams: BaseCrlResolution,\n): Promise<ReturnType<typeof buildCrlRevokedStatus> | undefined> {\n\tconst {\n\t\tcert,\n\t\tbaseCrl,\n\t\tapplicableDelta,\n\t\tcrlThisUpdate,\n\t\tissuer,\n\t\textraCertificates,\n\t\tchain,\n\t\tat,\n\t\tsignerCtx,\n\t\tstate,\n\t} = params;\n\tfor (const candidate of collectCrlSignerCandidates(baseCrl, issuer, extraCertificates, chain)) {\n\t\tconst checked = await checkCrlWithIssuer(cert, baseCrl, applicableDelta, candidate, at);\n\t\tif (!checked.ok) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (!(await crlSignerChainsToAnchor(candidate, chain, extraCertificates, at))) {\n\t\t\tstate.sawCrlSignerNotAuthorized = true;\n\t\t\tcontinue;\n\t\t}\n\t\tconst signerStatus = await validateCrlSigner(candidate, signerCtx);\n\t\tif (signerStatus === 'resolved-revoked') {\n\t\t\tstate.sawCrlSignerRevoked = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (signerStatus === 'resolved-indeterminate') {\n\t\t\tstate.sawCrlSignerIndeterminate = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (checked.value.status === 'revoked') {\n\t\t\treturn buildCrlRevokedStatus(\n\t\t\t\tcert,\n\t\t\t\tcandidate,\n\t\t\t\tcrlThisUpdate,\n\t\t\t\tchecked.value.revocationDate,\n\t\t\t\tchecked.value.reasonCode,\n\t\t\t);\n\t\t}\n\t\trecordGoodCrlEvidence(state, candidate, crlThisUpdate, checked.value.coveredReasons);\n\t\treturn undefined;\n\t}\n\treturn undefined;\n}\n\nasync function evaluateCrlEvidence(\n\tcert: ParsedCertificate,\n\tissuer: ParsedCertificate,\n\tinput: CheckChainRevocationInput,\n\tsignerCtx: SignerValidationContext,\n): Promise<EvidenceEvaluation> {\n\tconst { crls = [], extraCertificates = [], chain = [], at = new Date() } = input;\n\tconst state: CrlEvidenceState = {\n\t\texecutionErrors: [],\n\t\tcoveredReasons: new Set(),\n\t\tsawCrlSignerRevoked: false,\n\t\tsawCrlSignerIndeterminate: false,\n\t\tsawCrlSignerNotAuthorized: false,\n\t\tsawGood: false,\n\t};\n\n\t// Parse all CRLs and separate base CRLs from delta CRLs\n\tconst parsedCrls = parseCrlEvidenceSources(crls, state.executionErrors);\n\n\tconst baseCrls = parsedCrls.filter((crl) => crl.baseCrlNumber === undefined);\n\tconst deltaCrls = parsedCrls.filter((crl) => crl.baseCrlNumber !== undefined);\n\n\t// Process base CRLs (optionally paired with delta CRLs)\n\tfor (const baseCrl of baseCrls) {\n\t\tconst applicableDelta = findApplicableDeltaCrl(baseCrl, deltaCrls);\n\t\t// Evidence freshness: an applied delta CRL supersedes its base\n\t\tconst crlThisUpdate =\n\t\t\tapplicableDelta !== undefined &&\n\t\t\tapplicableDelta.thisUpdate.getTime() > baseCrl.thisUpdate.getTime()\n\t\t\t\t? applicableDelta.thisUpdate\n\t\t\t\t: baseCrl.thisUpdate;\n\t\tconst revoked = await resolveBaseCrlAgainstSigners({\n\t\t\tcert,\n\t\t\tbaseCrl,\n\t\t\tapplicableDelta,\n\t\t\tcrlThisUpdate,\n\t\t\tissuer,\n\t\t\textraCertificates,\n\t\t\tchain,\n\t\t\tat,\n\t\t\tsignerCtx,\n\t\t\tstate,\n\t\t});\n\t\tif (revoked !== undefined) {\n\t\t\treturn { status: revoked, executionErrors: state.executionErrors };\n\t\t}\n\t}\n\n\t// Return 'good' only if we saw at least one good result AND all reasons are covered\n\tif (state.sawGood && state.freshestGood !== undefined) {\n\t\tconst allReasonsCovered = coversAllDistributionPointReasons(state.coveredReasons);\n\t\tif (allReasonsCovered) {\n\t\t\treturn {\n\t\t\t\tstatus: {\n\t\t\t\t\tcertificate: cert,\n\t\t\t\t\tstatus: 'good',\n\t\t\t\t\tsource: {\n\t\t\t\t\t\tkind: 'crl',\n\t\t\t\t\t\tsignerCertificate: state.freshestGood.signer,\n\t\t\t\t\t\tthisUpdate: state.freshestGood.thisUpdate,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\texecutionErrors: state.executionErrors,\n\t\t\t};\n\t\t}\n\t\t// Not all reasons covered — indeterminate\n\t\treturn {\n\t\t\tstatus: {\n\t\t\t\tcertificate: cert,\n\t\t\t\tstatus: 'indeterminate',\n\t\t\t\tindeterminateReasons: ['reason_coverage_incomplete'],\n\t\t\t},\n\t\t\texecutionErrors: state.executionErrors,\n\t\t};\n\t}\n\n\treturn {\n\t\tstatus: {\n\t\t\tcertificate: cert,\n\t\t\tstatus: 'indeterminate',\n\t\t\tindeterminateReasons: [crlUnavailableReason(state)],\n\t\t},\n\t\texecutionErrors: state.executionErrors,\n\t};\n}\n\n/** Most specific indeterminate reason when no CRL yielded a usable verdict. */\nfunction crlUnavailableReason(state: CrlEvidenceState): RevocationIndeterminateReason {\n\tif (state.sawCrlSignerRevoked) {\n\t\treturn 'crl_signer_revoked';\n\t}\n\tif (state.sawCrlSignerNotAuthorized) {\n\t\treturn 'crl_signer_not_authorized';\n\t}\n\tif (state.sawCrlSignerIndeterminate) {\n\t\treturn 'crl_signer_indeterminate';\n\t}\n\treturn 'no_applicable_crl';\n}\n\n/** Parses complete and delta CRL evidence while retaining source provenance. */\nfunction parseCrlEvidenceSources(\n\tcrls: readonly CrlSource[],\n\texecutionErrors: RevocationExecutionError[],\n): readonly ParsedCertificateRevocationList[] {\n\tconst parsedCrls: ParsedCertificateRevocationList[] = [];\n\tfor (const crlSource of crls) {\n\t\ttry {\n\t\t\tparsedCrls.push(parseCrlFromSource(crlSource));\n\t\t} catch (e) {\n\t\t\texecutionErrors.push({\n\t\t\t\tkind: 'parse_error',\n\t\t\t\tmessage: e instanceof Error ? e.message : 'CRL parse failed',\n\t\t\t});\n\t\t}\n\t}\n\treturn parsedCrls;\n}\n\nfunction findApplicableDeltaCrl(\n\tbaseCrl: ParsedCertificateRevocationList,\n\tdeltaCrls: readonly ParsedCertificateRevocationList[],\n): ParsedCertificateRevocationList | undefined {\n\treturn deltaCrls.find(\n\t\t(deltaCrl) =>\n\t\t\tdeltaCrl.issuer.derHex === baseCrl.issuer.derHex &&\n\t\t\tdeltaCrl.baseCrlNumber !== undefined &&\n\t\t\tbaseCrl.crlNumber !== undefined &&\n\t\t\tBigInt(deltaCrl.baseCrlNumber) <= BigInt(baseCrl.crlNumber),\n\t);\n}\n\n/** The direct issuer first, then deduplicated indirect CRL-issuer candidates. */\nfunction collectCrlSignerCandidates(\n\tbaseCrl: ParsedCertificateRevocationList,\n\tissuer: ParsedCertificate,\n\textraCertificates: readonly RevocationCertificateSource[],\n\tchain: readonly ParsedCertificate[],\n): readonly ParsedCertificate[] {\n\tconst candidates: ParsedCertificate[] = [issuer];\n\tfor (const indirect of findIndirectCrlIssuers(baseCrl, extraCertificates, chain)) {\n\t\tif (!candidates.some((existing) => sameCertificate(existing, indirect))) {\n\t\t\tcandidates.push(indirect);\n\t\t}\n\t}\n\treturn candidates;\n}\n\nfunction checkCrlWithIssuer(\n\tcert: ParsedCertificate,\n\tcrl: ParsedCertificateRevocationList,\n\tdeltaCrl: ParsedCertificateRevocationList | undefined,\n\tcrlIssuer: ParsedCertificate,\n\tat: Date,\n): ReturnType<typeof checkCertificateRevocationAgainstCrl> {\n\treturn checkCertificateRevocationAgainstCrl({\n\t\tcertificate: cert,\n\t\tissuerCertificate: crlIssuer,\n\t\tcrl,\n\t\t...(deltaCrl !== undefined ? { deltaCrl } : {}),\n\t\tat,\n\t});\n}\n\nfunction recordGoodCrlEvidence(\n\tstate: CrlEvidenceState,\n\tsigner: ParsedCertificate,\n\tthisUpdate: Date,\n\tcoveredReasons: readonly DistributionPointReason[],\n): void {\n\tstate.sawGood = true;\n\tif (\n\t\tstate.freshestGood === undefined ||\n\t\tthisUpdate.getTime() > state.freshestGood.thisUpdate.getTime()\n\t) {\n\t\tstate.freshestGood = { signer, thisUpdate };\n\t}\n\tfor (const reason of coveredReasons) {\n\t\tstate.coveredReasons.add(reason);\n\t}\n}\n\n/**\n * Evaluates revocation status for a single certificate by combining OCSP and\n * CRL evidence.\n *\n * Both evidence kinds are always evaluated: a validated `revoked` verdict from\n * either source wins regardless of {@linkcode RevocationPolicy.prefer}\n * (fail-closed). Otherwise the preferred source's `good` verdict is reported —\n * for `'best-available'` the source with the later evidence `thisUpdate` wins,\n * ties favoring OCSP. If neither source is definitive, indeterminate reasons\n * from both are merged.\n */\nasync function evaluateCertificateRevocation(\n\tcert: ParsedCertificate,\n\tissuer: ParsedCertificate,\n\tinput: CheckChainRevocationInput,\n\tsignerCtx: SignerValidationContext,\n): Promise<EvidenceEvaluation> {\n\tconst prefer = input.policy?.prefer ?? 'best-available';\n\tconst ocsp = await evaluateOcspEvidence(cert, issuer, input);\n\tconst crl = await evaluateCrlEvidence(cert, issuer, input, signerCtx);\n\tconst executionErrors = [...ocsp.executionErrors, ...crl.executionErrors];\n\n\t// 'best-available' ranks by evidence freshness; the sort is stable, so\n\t// equal (or absent) thisUpdate keeps OCSP first.\n\tconst ordered =\n\t\tprefer === 'crl'\n\t\t\t? [crl, ocsp]\n\t\t\t: prefer === 'ocsp'\n\t\t\t\t? [ocsp, crl]\n\t\t\t\t: [ocsp, crl].sort(\n\t\t\t\t\t\t(a, b) =>\n\t\t\t\t\t\t\t(b.status.source?.thisUpdate?.getTime() ?? 0) -\n\t\t\t\t\t\t\t(a.status.source?.thisUpdate?.getTime() ?? 0),\n\t\t\t\t\t);\n\tconst revoked = ordered.find((evaluation) => evaluation.status.status === 'revoked');\n\tif (revoked !== undefined) {\n\t\treturn { status: revoked.status, executionErrors };\n\t}\n\tconst good = ordered.find((evaluation) => evaluation.status.status === 'good');\n\tif (good !== undefined) {\n\t\treturn { status: good.status, executionErrors };\n\t}\n\n\tconst reasons = new Set<RevocationIndeterminateReason>();\n\tfor (const evaluation of ordered) {\n\t\tfor (const reason of evaluation.status.indeterminateReasons ?? []) {\n\t\t\treasons.add(reason);\n\t\t}\n\t}\n\treturn {\n\t\tstatus: {\n\t\t\tcertificate: cert,\n\t\t\tstatus: 'indeterminate',\n\t\t\tindeterminateReasons: [...reasons],\n\t\t},\n\t\texecutionErrors,\n\t};\n}\n\n// Function\n\n/**\n * Checks revocation status for all certificates in a validated chain.\n *\n * Evaluates CRL and OCSP evidence against each certificate (except the trust\n * anchor), applies the revocation policy, and returns a unified decision.\n *\n * @example\n * ```ts\n * const result = await checkChainRevocation({\n * chain: validatedChain,\n * crls: [crl1, crl2],\n * ocspResponses: [ocspResponseDer],\n * policy: { mode: 'hard-fail' },\n * });\n * if (result.value.decision === 'deny') {\n * console.log('Revocation check failed');\n * }\n * ```\n */\nexport async function checkChainRevocation(\n\tinput: CheckChainRevocationInput,\n): Promise<CheckChainRevocationResult> {\n\tconst { chain, policy, crls = [], extraCertificates = [], at = new Date() } = input;\n\tconst mode = policy?.mode ?? 'hard-fail';\n\n\t// Empty chain → allow\n\tif (chain.length === 0) {\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: {\n\t\t\t\tdecision: 'allow',\n\t\t\t\tsummary: { revokedCertificates: [], indeterminateCertificates: [] },\n\t\t\t\tcertificates: [],\n\t\t\t},\n\t\t};\n\t}\n\n\t// Create signer validation context with memoization cache\n\t// This cache is shared across all certificate checks in this chain evaluation\n\tconst signerCtx: SignerValidationContext = {\n\t\tcache: new Map(),\n\t\tchain,\n\t\tcrls,\n\t\textraCertificates,\n\t\tat,\n\t};\n\n\t// Skip trust anchor (last cert) — it's the trust base\n\tconst certsToCheck = chain.slice(0, -1);\n\tconst certificates: CertificateRevocationStatus[] = [];\n\tconst revokedCertificates: ParsedCertificate[] = [];\n\tconst indeterminateCertificates: ParsedCertificate[] = [];\n\tconst allExecutionErrors: RevocationExecutionError[] = [];\n\n\tfor (let i = 0; i < certsToCheck.length; i++) {\n\t\tconst cert = certsToCheck[i];\n\t\tconst issuer = chain[i + 1]; // Next cert in chain is the issuer\n\t\tif (cert === undefined || issuer === undefined) {\n\t\t\tcontinue; // Should never happen given loop bounds\n\t\t}\n\n\t\tconst { status, executionErrors } = await evaluateCertificateRevocation(\n\t\t\tcert,\n\t\t\tissuer,\n\t\t\tinput,\n\t\t\tsignerCtx,\n\t\t);\n\t\tcertificates.push(status);\n\t\tallExecutionErrors.push(...executionErrors);\n\n\t\tif (status.status === 'revoked') {\n\t\t\trevokedCertificates.push(cert);\n\t\t} else if (status.status === 'indeterminate') {\n\t\t\tindeterminateCertificates.push(cert);\n\t\t}\n\t}\n\n\t// Apply policy\n\tconst hasRevoked = revokedCertificates.length > 0;\n\tconst hasIndeterminate = indeterminateCertificates.length > 0;\n\tconst decision: 'allow' | 'deny' = hasRevoked\n\t\t? 'deny'\n\t\t: hasIndeterminate && mode === 'hard-fail'\n\t\t\t? 'deny'\n\t\t\t: 'allow';\n\n\treturn {\n\t\tok: true,\n\t\tvalue: {\n\t\t\tdecision,\n\t\t\tsummary: { revokedCertificates, indeterminateCertificates },\n\t\t\tcertificates,\n\t\t\t...(allExecutionErrors.length > 0 ? { executionErrors: allExecutionErrors } : {}),\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiIA,MAAa,IAAmC;CAE/C;CACA;CAEA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CA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AAC,GAClD,IAAiD,CAAC;CAExD,KAAK,IAAI,IAAI,GAAG,IAAI,EAAa,QAAQ,KAAK;EAC7C,IAAM,IAAO,EAAa,IACpB,IAAS,EAAM,IAAI;EACzB,IAAI,MAAS,KAAA,KAAa,MAAW,KAAA,GACpC;EAGD,IAAM,EAAE,WAAQ,uBAAoB,MAAM,8BACzC,GACA,GACA,GACA,CACD;EAIA,AAHA,EAAa,KAAK,CAAM,GACxB,EAAmB,KAAK,GAAG,CAAe,GAEtC,EAAO,WAAW,YACrB,EAAoB,KAAK,CAAI,IACnB,EAAO,WAAW,mBAC5B,EAA0B,KAAK,CAAI;CAErC;CAGA,IAAM,IAAa,EAAoB,SAAS,GAC1C,IAAmB,EAA0B,SAAS;CAO5D,OAAO;EACN,IAAI;EACJ,OAAO;GACN,UATiC,KAEhC,KAAoB,MAAS,cAD7B,SAGC;GAMF,SAAS;IAAE;IAAqB;GAA0B;GAC1D;GACA,GAAI,EAAmB,SAAS,IAAI,EAAE,iBAAiB,EAAmB,IAAI,CAAC;EAChF;CACD;AACD"}
|
package/dist/revocation/crl.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ErrorResult, Micro509Error } from "../result/result.js";
|
|
2
2
|
import { NameInput } from "../x509/name.js";
|
|
3
|
-
import { DistributionPoint, GeneralName, IssuingDistributionPoint } from "../x509/extensions.js";
|
|
3
|
+
import { DistributionPoint, DistributionPointReason, GeneralName, IssuingDistributionPoint } from "../x509/extensions.js";
|
|
4
4
|
import { ParsedCertificate, ParsedDistributionPoint, ParsedIssuingDistributionPoint, ParsedName } from "../x509/parse.js";
|
|
5
5
|
//#region src/revocation/crl.d.ts
|
|
6
6
|
/**
|
|
@@ -203,6 +203,13 @@ interface CheckCertificateRevocationAgainstCrlGoodValue {
|
|
|
203
203
|
readonly status: "good";
|
|
204
204
|
/** The validated CRL that was checked. */
|
|
205
205
|
readonly crl: ParsedCertificateRevocationList;
|
|
206
|
+
/**
|
|
207
|
+
* Revocation reasons this check covered, the RFC 5280 §6.3.3 (d)
|
|
208
|
+
* interim_reasons_mask: the matched distribution point's reasons intersected
|
|
209
|
+
* with the CRL's `onlySomeReasons`, either alone when the other is absent,
|
|
210
|
+
* or every reason when both are.
|
|
211
|
+
*/
|
|
212
|
+
readonly coveredReasons: readonly DistributionPointReason[];
|
|
206
213
|
}
|
|
207
214
|
/** Success value when the certificate is found as revoked in the CRL. */
|
|
208
215
|
interface CheckCertificateRevocationAgainstCrlRevokedValue {
|
|
@@ -340,6 +347,10 @@ declare function checkCertificateRevocationAgainstCrl(input: CheckCertificateRev
|
|
|
340
347
|
* CRL's revoked entries. Does **not** validate the CRL or check applicability.
|
|
341
348
|
*/
|
|
342
349
|
declare function isCertificateRevoked(certificateSerialNumber: Uint8Array | string, crl: ParsedCertificateRevocationList): boolean;
|
|
350
|
+
/** Machine-readable reason a CRL encoder rejected its construction input. */
|
|
351
|
+
type CrlEncoderErrorCode = "distribution_point_full_name_empty" | "issuer_distinguished_name_empty";
|
|
352
|
+
/** Maps an integer CRLReason code back to its {@linkcode RevocationReason} string, or `undefined` for unknown codes. */
|
|
353
|
+
declare function revocationReasonFromCode(code: number | undefined): RevocationReason | undefined;
|
|
343
354
|
//#endregion
|
|
344
|
-
export { CertificateRevocationListMaterial, CheckCertificateRevocationAgainstCrlErrorCode, CheckCertificateRevocationAgainstCrlFailure, CheckCertificateRevocationAgainstCrlFailureDetails, CheckCertificateRevocationAgainstCrlGoodValue, CheckCertificateRevocationAgainstCrlInput, CheckCertificateRevocationAgainstCrlResult, CheckCertificateRevocationAgainstCrlRevokedValue, CheckCertificateRevocationAgainstCrlValue, CreateCertificateRevocationListInput, CrlApplicabilityFailureReason, CrlCertificateSource, CrlSource, ParseCertificateRevocationListErrorCode, ParseCertificateRevocationListFailure, ParseCertificateRevocationListResult, ParsedCertificateRevocationList, ParsedRevokedCertificate, RevocationReason, RevokedCertificateInput, ValidateCertificateRevocationListFailure, ValidateCertificateRevocationListInput, ValidateCertificateRevocationListResult, VerifyCertificateRevocationListSignatureFailure, VerifyCertificateRevocationListSignatureResult, checkCertificateRevocationAgainstCrl, createCertificateRevocationList, isCertificateRevoked, parseCertificateRevocationListDer, parseCertificateRevocationListDerOrThrow, parseCertificateRevocationListPem, parseCertificateRevocationListPemOrThrow, validateCertificateRevocationList, verifyCertificateRevocationListSignature };
|
|
355
|
+
export { CertificateRevocationListMaterial, CheckCertificateRevocationAgainstCrlErrorCode, CheckCertificateRevocationAgainstCrlFailure, CheckCertificateRevocationAgainstCrlFailureDetails, CheckCertificateRevocationAgainstCrlGoodValue, CheckCertificateRevocationAgainstCrlInput, CheckCertificateRevocationAgainstCrlResult, CheckCertificateRevocationAgainstCrlRevokedValue, CheckCertificateRevocationAgainstCrlValue, CreateCertificateRevocationListInput, CrlApplicabilityFailureReason, CrlCertificateSource, CrlEncoderErrorCode, CrlSource, ParseCertificateRevocationListErrorCode, ParseCertificateRevocationListFailure, ParseCertificateRevocationListResult, ParsedCertificateRevocationList, ParsedRevokedCertificate, RevocationReason, RevokedCertificateInput, ValidateCertificateRevocationListFailure, ValidateCertificateRevocationListInput, ValidateCertificateRevocationListResult, VerifyCertificateRevocationListSignatureFailure, VerifyCertificateRevocationListSignatureResult, checkCertificateRevocationAgainstCrl, createCertificateRevocationList, isCertificateRevoked, parseCertificateRevocationListDer, parseCertificateRevocationListDerOrThrow, parseCertificateRevocationListPem, parseCertificateRevocationListPemOrThrow, revocationReasonFromCode, validateCertificateRevocationList, verifyCertificateRevocationListSignature };
|
|
345
356
|
//# sourceMappingURL=crl.d.ts.map
|