micro509 0.12.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 +127 -0
- package/dist/der/der.js +171 -0
- package/dist/der/der.js.map +1 -0
- package/dist/der.d.ts +4 -0
- package/dist/der.js +4 -0
- package/dist/index.d.ts +13 -9
- package/dist/index.js +17 -15
- package/dist/internal/asn1/asn1.d.ts +20 -0
- package/dist/internal/asn1/asn1.js +80 -37
- package/dist/internal/asn1/asn1.js.map +1 -1
- package/dist/internal/asn1/der.d.ts +173 -0
- package/dist/internal/asn1/der.js +116 -38
- package/dist/internal/asn1/der.js.map +1 -1
- package/dist/internal/asn1/oids.js +7 -1
- package/dist/internal/asn1/oids2.js +9 -2
- package/dist/internal/asn1/oids2.js.map +1 -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 +149 -12
- 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/shared/rfc3454-tables.js +1782 -0
- package/dist/internal/shared/rfc3454-tables.js.map +1 -0
- package/dist/internal/verify/name-constraints-engine.js +47 -15
- package/dist/internal/verify/name-constraints-engine.js.map +1 -1
- package/dist/internal/verify/policy-engine.js +85 -94
- package/dist/internal/verify/policy-engine.js.map +1 -1
- package/dist/internal/verify/verify-path.d.ts +7 -0
- package/dist/internal/verify/verify-path.js +49 -45
- package/dist/internal/verify/verify-path.js.map +1 -1
- 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 +14 -11
- 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 +154 -103
- 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 +186 -174
- 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 +18 -3
- package/dist/verify/verify.js +66 -41
- 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 +59 -22
- 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 +52 -34
package/dist/revocation/chain.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { parseCertificateFromSource as e } from "../x509/parse.js";
|
|
2
|
-
import { checkCertificateRevocationAgainstCrl as t,
|
|
3
|
-
import {
|
|
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";
|
|
4
5
|
//#region src/revocation/chain.ts
|
|
5
6
|
/**
|
|
6
7
|
* Granular reasons why revocation status could not be determined.
|
|
@@ -15,7 +16,7 @@ import { parseOcspResponseDerOrThrow as a, parseOcspResponsePemOrThrow as o, val
|
|
|
15
16
|
* `crl_signer_revoked`, `crl_signer_indeterminate`, and OCSP equivalents
|
|
16
17
|
* - **Freshness**: `crl_expired`, `ocsp_response_expired`
|
|
17
18
|
*/
|
|
18
|
-
const
|
|
19
|
+
const u = [
|
|
19
20
|
"no_applicable_crl",
|
|
20
21
|
"no_applicable_ocsp",
|
|
21
22
|
"distribution_point_mismatch",
|
|
@@ -39,7 +40,7 @@ const c = [
|
|
|
39
40
|
* Parses a CRL from various source formats.
|
|
40
41
|
*/
|
|
41
42
|
function parseCrlFromSource(e) {
|
|
42
|
-
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);
|
|
43
44
|
}
|
|
44
45
|
/**
|
|
45
46
|
* Parses a certificate from various source formats, returning undefined on failure.
|
|
@@ -61,26 +62,57 @@ function sameCertificate(e, t) {
|
|
|
61
62
|
return !0;
|
|
62
63
|
}
|
|
63
64
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
65
|
+
* Yields every certificate that could have signed the given CRL, AKI/SKI
|
|
66
|
+
* matches before DN matches. All candidates are returned so a certificate whose
|
|
67
|
+
* subject DN collides with the genuine CRL issuer cannot shadow it: each is
|
|
68
|
+
* tried against the CRL signature and its own path to the trust anchor.
|
|
66
69
|
*/
|
|
67
|
-
function
|
|
70
|
+
function findIndirectCrlIssuers(e, t, n) {
|
|
68
71
|
let r = [];
|
|
69
72
|
for (let e of t) {
|
|
70
73
|
let t = parseCertificateSafe(e);
|
|
71
74
|
t !== void 0 && r.push(t);
|
|
72
75
|
}
|
|
73
|
-
let i = [...r, ...n]
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
for (let t of i)
|
|
76
|
+
let i = [...r, ...n], a = [], push = (e) => {
|
|
77
|
+
a.some((t) => sameCertificate(t, e)) || a.push(e);
|
|
78
|
+
};
|
|
79
|
+
if (e.authorityKeyIdentifier !== void 0) for (let t of i) t.subjectKeyIdentifier !== void 0 && normalizeHex(e.authorityKeyIdentifier) === normalizeHex(t.subjectKeyIdentifier) && push(t);
|
|
80
|
+
for (let t of i) e.issuer.derHex === t.subject.derHex && push(t);
|
|
81
|
+
return a;
|
|
78
82
|
}
|
|
79
83
|
/** Lowercases a hex string for bytewise comparison. */
|
|
80
84
|
function normalizeHex(e) {
|
|
81
85
|
return e.toLowerCase();
|
|
82
86
|
}
|
|
83
87
|
/**
|
|
88
|
+
* RFC 5280 §6.3.3(f): confirms the CRL issuer certificate has a valid
|
|
89
|
+
* certification path to the same trust anchor as the certificate under test. A
|
|
90
|
+
* signer already inside the validated chain is authorized by construction. The
|
|
91
|
+
* path check runs without revocation to avoid unbounded recursion.
|
|
92
|
+
*/
|
|
93
|
+
async function crlSignerChainsToAnchor(e, t, n, r) {
|
|
94
|
+
if (t.some((t) => sameCertificate(t, e))) return !0;
|
|
95
|
+
let i = t[t.length - 1];
|
|
96
|
+
if (i === void 0) return !1;
|
|
97
|
+
let a = [], addCandidate = (t) => {
|
|
98
|
+
sameCertificate(t, e) || sameCertificate(t, i) || a.some((e) => sameCertificate(e, t)) || a.push(t);
|
|
99
|
+
};
|
|
100
|
+
for (let e = 0; e < t.length - 1; e += 1) {
|
|
101
|
+
let n = t[e];
|
|
102
|
+
n !== void 0 && addCandidate(n);
|
|
103
|
+
}
|
|
104
|
+
for (let e of n) {
|
|
105
|
+
let t = parseCertificateSafe(e);
|
|
106
|
+
t !== void 0 && addCandidate(t);
|
|
107
|
+
}
|
|
108
|
+
return (await o({
|
|
109
|
+
leaf: e.der,
|
|
110
|
+
intermediates: a.map((e) => e.der),
|
|
111
|
+
roots: [i.der],
|
|
112
|
+
at: r
|
|
113
|
+
})).ok;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
84
116
|
* Builds a unique cache key for a certificate.
|
|
85
117
|
* Uses issuer DN + serial number which uniquely identifies a cert.
|
|
86
118
|
*/
|
|
@@ -120,27 +152,41 @@ function findSignerIssuer(e, t) {
|
|
|
120
152
|
* Checks if a CRL signer certificate is revoked by examining available CRLs.
|
|
121
153
|
* Recursively validates the CRL signer of any CRL used to check revocation.
|
|
122
154
|
*/
|
|
123
|
-
async function checkSignerRevocation(e,
|
|
124
|
-
let i = r.chain.some((e) => sameCertificate(e,
|
|
125
|
-
for (let
|
|
126
|
-
let
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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);
|
|
161
|
+
}
|
|
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;
|
|
142
179
|
}
|
|
143
|
-
|
|
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;
|
|
144
190
|
}
|
|
145
191
|
/** Builds the `revoked` CertificateRevocationStatus for a CRL hit. */
|
|
146
192
|
function buildCrlRevokedStatus(e, t, n, r, i) {
|
|
@@ -160,7 +206,7 @@ function buildCrlRevokedStatus(e, t, n, r, i) {
|
|
|
160
206
|
}
|
|
161
207
|
/** Parses an OCSP response from PEM string or DER bytes. */
|
|
162
208
|
function parseOcspResponseFromSource(e) {
|
|
163
|
-
return typeof e == "string" ?
|
|
209
|
+
return typeof e == "string" ? c(e) : s(e);
|
|
164
210
|
}
|
|
165
211
|
/** Maps a {@linkcode validateOcspResponse} failure code to an indeterminate reason. */
|
|
166
212
|
function ocspIndeterminateReasonFromFailure(e) {
|
|
@@ -176,10 +222,11 @@ function ocspIndeterminateReasonFromFailure(e) {
|
|
|
176
222
|
case "issuer_mismatch":
|
|
177
223
|
case "nonce_mismatch":
|
|
178
224
|
case "request_mismatch": return "no_applicable_ocsp";
|
|
225
|
+
default: throw Error(`Unhandled ValidateOcspResponse failure code: ${String(e)}`);
|
|
179
226
|
}
|
|
180
227
|
}
|
|
181
228
|
/** Validation failures worth retrying with an explicit responder certificate. */
|
|
182
|
-
const
|
|
229
|
+
const f = /* @__PURE__ */ new Set([
|
|
183
230
|
"signature_invalid",
|
|
184
231
|
"responder_id_mismatch",
|
|
185
232
|
"responder_chain_invalid",
|
|
@@ -196,15 +243,15 @@ async function validateOcspResponseWithResponderFallback(e, t, n, r) {
|
|
|
196
243
|
...n.trustedOcspResponders === void 0 ? {} : { trustedOcspResponders: n.trustedOcspResponders },
|
|
197
244
|
...n.policy?.ocspResponderRevocation === void 0 ? {} : { responderRevocationPolicy: n.policy.ocspResponderRevocation },
|
|
198
245
|
...n.crls === void 0 ? {} : { responderRevocationCrls: n.crls }
|
|
199
|
-
}, a = await
|
|
246
|
+
}, a = await l({
|
|
200
247
|
response: e,
|
|
201
248
|
...i
|
|
202
249
|
});
|
|
203
|
-
if (a.ok || !
|
|
250
|
+
if (a.ok || !f.has(a.code)) return a;
|
|
204
251
|
for (let t of n.extraCertificates ?? []) {
|
|
205
252
|
let n = parseCertificateSafe(t);
|
|
206
253
|
if (n === void 0) continue;
|
|
207
|
-
let r = await
|
|
254
|
+
let r = await l({
|
|
208
255
|
response: e,
|
|
209
256
|
...i,
|
|
210
257
|
responderCertificate: n
|
|
@@ -223,7 +270,7 @@ async function validateOcspResponseWithResponderFallback(e, t, n, r) {
|
|
|
223
270
|
* sufficient to attribute the entry to `cert`.
|
|
224
271
|
*/
|
|
225
272
|
async function evaluateOcspEvidence(e, t, n) {
|
|
226
|
-
let { ocspResponses: r = [], at:
|
|
273
|
+
let { ocspResponses: r = [], at: i = /* @__PURE__ */ new Date() } = n, o = [], s = /* @__PURE__ */ new Set();
|
|
227
274
|
for (let c of r) {
|
|
228
275
|
let r;
|
|
229
276
|
try {
|
|
@@ -237,13 +284,13 @@ async function evaluateOcspEvidence(e, t, n) {
|
|
|
237
284
|
}
|
|
238
285
|
let l = (r.responses ?? []).find((t) => normalizeHex(t.certId.serialNumberHex) === normalizeHex(e.serialNumberHex));
|
|
239
286
|
if (l === void 0) continue;
|
|
240
|
-
let u = await validateOcspResponseWithResponderFallback(r, t, n,
|
|
287
|
+
let u = await validateOcspResponseWithResponderFallback(r, t, n, i);
|
|
241
288
|
if (!u.ok) {
|
|
242
289
|
s.add(ocspIndeterminateReasonFromFailure(u.code));
|
|
243
290
|
continue;
|
|
244
291
|
}
|
|
245
292
|
if (l.certStatus === "revoked") {
|
|
246
|
-
let t =
|
|
293
|
+
let t = a(l.revocationReasonCode);
|
|
247
294
|
return {
|
|
248
295
|
status: {
|
|
249
296
|
certificate: e,
|
|
@@ -283,80 +330,94 @@ async function evaluateOcspEvidence(e, t, n) {
|
|
|
283
330
|
};
|
|
284
331
|
}
|
|
285
332
|
/**
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
* Also validates that CRL signers are not revoked (RFC 5280 §6.3.3).
|
|
333
|
+
* Runs each candidate signer through the full pipeline for one base CRL:
|
|
334
|
+
* signature/applicability, RFC 5280 §6.3.3(f) path to the anchor, then signer
|
|
335
|
+
* revocation. A candidate that verifies the signature but fails a later step
|
|
336
|
+
* does not shadow a subsequent usable signer, so the search continues. Returns
|
|
337
|
+
* a revoked status when one is found; otherwise records good or diagnostic
|
|
338
|
+
* evidence into `state`.
|
|
293
339
|
*/
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
340
|
+
async function resolveBaseCrlAgainstSigners(e) {
|
|
341
|
+
let { cert: t, baseCrl: n, applicableDelta: r, crlThisUpdate: i, issuer: a, extraCertificates: o, chain: s, at: c, signerCtx: l, state: u } = e;
|
|
342
|
+
for (let e of collectCrlSignerCandidates(n, a, o, s)) {
|
|
343
|
+
let a = await checkCrlWithIssuer(t, n, r, e, c);
|
|
344
|
+
if (!a.ok) continue;
|
|
345
|
+
if (!await crlSignerChainsToAnchor(e, s, o, c)) {
|
|
346
|
+
u.sawCrlSignerNotAuthorized = !0;
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
let d = await validateCrlSigner(e, l);
|
|
350
|
+
if (d === "resolved-revoked") {
|
|
351
|
+
u.sawCrlSignerRevoked = !0;
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
if (d === "resolved-indeterminate") {
|
|
355
|
+
u.sawCrlSignerIndeterminate = !0;
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
if (a.value.status === "revoked") return buildCrlRevokedStatus(t, e, i, a.value.revocationDate, a.value.reasonCode);
|
|
359
|
+
recordGoodCrlEvidence(u, e, i, a.value.coveredReasons);
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
async function evaluateCrlEvidence(e, t, r, i) {
|
|
364
|
+
let { crls: a = [], extraCertificates: o = [], chain: s = [], at: c = /* @__PURE__ */ new Date() } = r, l = {
|
|
306
365
|
executionErrors: [],
|
|
307
366
|
coveredReasons: /* @__PURE__ */ new Set(),
|
|
308
367
|
sawCrlSignerRevoked: !1,
|
|
309
368
|
sawCrlSignerIndeterminate: !1,
|
|
369
|
+
sawCrlSignerNotAuthorized: !1,
|
|
310
370
|
sawGood: !1
|
|
311
|
-
},
|
|
371
|
+
}, u = parseCrlEvidenceSources(a, l.executionErrors), d = u.filter((e) => e.baseCrlNumber === void 0), f = u.filter((e) => e.baseCrlNumber !== void 0);
|
|
312
372
|
for (let n of d) {
|
|
313
|
-
let
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
c
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
if (
|
|
326
|
-
status:
|
|
327
|
-
executionErrors:
|
|
373
|
+
let r = findApplicableDeltaCrl(n, f), a = await resolveBaseCrlAgainstSigners({
|
|
374
|
+
cert: e,
|
|
375
|
+
baseCrl: n,
|
|
376
|
+
applicableDelta: r,
|
|
377
|
+
crlThisUpdate: r !== void 0 && r.thisUpdate.getTime() > n.thisUpdate.getTime() ? r.thisUpdate : n.thisUpdate,
|
|
378
|
+
issuer: t,
|
|
379
|
+
extraCertificates: o,
|
|
380
|
+
chain: s,
|
|
381
|
+
at: c,
|
|
382
|
+
signerCtx: i,
|
|
383
|
+
state: l
|
|
384
|
+
});
|
|
385
|
+
if (a !== void 0) return {
|
|
386
|
+
status: a,
|
|
387
|
+
executionErrors: l.executionErrors
|
|
328
388
|
};
|
|
329
|
-
recordGoodCrlEvidence(c, l.signer, d, n);
|
|
330
389
|
}
|
|
331
|
-
|
|
390
|
+
return l.sawGood && l.freshestGood !== void 0 ? n(l.coveredReasons) ? {
|
|
332
391
|
status: {
|
|
333
392
|
certificate: e,
|
|
334
393
|
status: "good",
|
|
335
394
|
source: {
|
|
336
395
|
kind: "crl",
|
|
337
|
-
signerCertificate:
|
|
338
|
-
thisUpdate:
|
|
396
|
+
signerCertificate: l.freshestGood.signer,
|
|
397
|
+
thisUpdate: l.freshestGood.thisUpdate
|
|
339
398
|
}
|
|
340
399
|
},
|
|
341
|
-
executionErrors:
|
|
400
|
+
executionErrors: l.executionErrors
|
|
342
401
|
} : {
|
|
343
402
|
status: {
|
|
344
403
|
certificate: e,
|
|
345
404
|
status: "indeterminate",
|
|
346
405
|
indeterminateReasons: ["reason_coverage_incomplete"]
|
|
347
406
|
},
|
|
348
|
-
executionErrors:
|
|
349
|
-
}
|
|
350
|
-
let p = [];
|
|
351
|
-
return c.sawCrlSignerRevoked ? p.push("crl_signer_revoked") : c.sawCrlSignerIndeterminate ? p.push("crl_signer_indeterminate") : p.push("no_applicable_crl"), {
|
|
407
|
+
executionErrors: l.executionErrors
|
|
408
|
+
} : {
|
|
352
409
|
status: {
|
|
353
410
|
certificate: e,
|
|
354
411
|
status: "indeterminate",
|
|
355
|
-
indeterminateReasons:
|
|
412
|
+
indeterminateReasons: [crlUnavailableReason(l)]
|
|
356
413
|
},
|
|
357
|
-
executionErrors:
|
|
414
|
+
executionErrors: l.executionErrors
|
|
358
415
|
};
|
|
359
416
|
}
|
|
417
|
+
/** Most specific indeterminate reason when no CRL yielded a usable verdict. */
|
|
418
|
+
function crlUnavailableReason(e) {
|
|
419
|
+
return e.sawCrlSignerRevoked ? "crl_signer_revoked" : e.sawCrlSignerNotAuthorized ? "crl_signer_not_authorized" : e.sawCrlSignerIndeterminate ? "crl_signer_indeterminate" : "no_applicable_crl";
|
|
420
|
+
}
|
|
360
421
|
/** Parses complete and delta CRL evidence while retaining source provenance. */
|
|
361
422
|
function parseCrlEvidenceSources(e, t) {
|
|
362
423
|
let n = [];
|
|
@@ -373,21 +434,11 @@ function parseCrlEvidenceSources(e, t) {
|
|
|
373
434
|
function findApplicableDeltaCrl(e, t) {
|
|
374
435
|
return t.find((t) => t.issuer.derHex === e.issuer.derHex && t.baseCrlNumber !== void 0 && e.crlNumber !== void 0 && BigInt(t.baseCrlNumber) <= BigInt(e.crlNumber));
|
|
375
436
|
}
|
|
376
|
-
/**
|
|
377
|
-
|
|
378
|
-
let
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
signer: r
|
|
382
|
-
};
|
|
383
|
-
let c = findIndirectCrlIssuer(t, i, a);
|
|
384
|
-
return c === void 0 || sameCertificate(c, r) ? {
|
|
385
|
-
result: s,
|
|
386
|
-
signer: r
|
|
387
|
-
} : {
|
|
388
|
-
result: await checkCrlWithIssuer(e, t, n, c, o),
|
|
389
|
-
signer: c
|
|
390
|
-
};
|
|
437
|
+
/** The direct issuer first, then deduplicated indirect CRL-issuer candidates. */
|
|
438
|
+
function collectCrlSignerCandidates(e, t, n, r) {
|
|
439
|
+
let i = [t];
|
|
440
|
+
for (let t of findIndirectCrlIssuers(e, n, r)) i.some((e) => sameCertificate(e, t)) || i.push(t);
|
|
441
|
+
return i;
|
|
391
442
|
}
|
|
392
443
|
function checkCrlWithIssuer(e, n, r, i, a) {
|
|
393
444
|
return t({
|
|
@@ -403,7 +454,7 @@ function recordGoodCrlEvidence(e, t, n, r) {
|
|
|
403
454
|
signer: t,
|
|
404
455
|
thisUpdate: n
|
|
405
456
|
});
|
|
406
|
-
for (let t of r
|
|
457
|
+
for (let t of r) e.coveredReasons.add(t);
|
|
407
458
|
}
|
|
408
459
|
/**
|
|
409
460
|
* Evaluates revocation status for a single certificate by combining OCSP and
|
|
@@ -498,6 +549,6 @@ async function checkChainRevocation(e) {
|
|
|
498
549
|
};
|
|
499
550
|
}
|
|
500
551
|
//#endregion
|
|
501
|
-
export {
|
|
552
|
+
export { u as REVOCATION_INDETERMINATE_REASONS, checkChainRevocation };
|
|
502
553
|
|
|
503
554
|
//# sourceMappingURL=chain.js.map
|