@browsercore/tls 0.4.18 → 0.4.20

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.
Files changed (69) hide show
  1. package/README.md +291 -6
  2. package/dist/certificates/ca-constraints.d.ts +43 -0
  3. package/dist/certificates/ca-constraints.d.ts.map +1 -0
  4. package/dist/certificates/ca-constraints.js +89 -0
  5. package/dist/certificates/ca-constraints.js.map +1 -0
  6. package/dist/certificates/cert-extensions.d.ts +106 -19
  7. package/dist/certificates/cert-extensions.d.ts.map +1 -1
  8. package/dist/certificates/cert-extensions.js +203 -48
  9. package/dist/certificates/cert-extensions.js.map +1 -1
  10. package/dist/certificates/certificate-path.d.ts +341 -0
  11. package/dist/certificates/certificate-path.d.ts.map +1 -0
  12. package/dist/certificates/certificate-path.js +613 -0
  13. package/dist/certificates/certificate-path.js.map +1 -0
  14. package/dist/certificates/certificates.d.ts +66 -47
  15. package/dist/certificates/certificates.d.ts.map +1 -1
  16. package/dist/certificates/certificates.js +251 -92
  17. package/dist/certificates/certificates.js.map +1 -1
  18. package/dist/certificates/der.d.ts +0 -8
  19. package/dist/certificates/der.d.ts.map +1 -1
  20. package/dist/certificates/der.js +0 -42
  21. package/dist/certificates/der.js.map +1 -1
  22. package/dist/certificates/extension-policy.d.ts +205 -0
  23. package/dist/certificates/extension-policy.d.ts.map +1 -0
  24. package/dist/certificates/extension-policy.js +357 -0
  25. package/dist/certificates/extension-policy.js.map +1 -0
  26. package/dist/certificates/extension-values.d.ts +131 -0
  27. package/dist/certificates/extension-values.d.ts.map +1 -0
  28. package/dist/certificates/extension-values.js +443 -0
  29. package/dist/certificates/extension-values.js.map +1 -0
  30. package/dist/certificates/general-names.d.ts +142 -0
  31. package/dist/certificates/general-names.d.ts.map +1 -0
  32. package/dist/certificates/general-names.js +354 -0
  33. package/dist/certificates/general-names.js.map +1 -0
  34. package/dist/certificates/name-constraints.d.ts +245 -0
  35. package/dist/certificates/name-constraints.d.ts.map +1 -0
  36. package/dist/certificates/name-constraints.js +692 -0
  37. package/dist/certificates/name-constraints.js.map +1 -0
  38. package/dist/certificates/name-match.d.ts +59 -0
  39. package/dist/certificates/name-match.d.ts.map +1 -0
  40. package/dist/certificates/name-match.js +271 -0
  41. package/dist/certificates/name-match.js.map +1 -0
  42. package/dist/certificates/signature-algorithm.d.ts +54 -0
  43. package/dist/certificates/signature-algorithm.d.ts.map +1 -0
  44. package/dist/certificates/signature-algorithm.js +359 -0
  45. package/dist/certificates/signature-algorithm.js.map +1 -0
  46. package/dist/connection/handshake-driver.d.ts +9 -6
  47. package/dist/connection/handshake-driver.d.ts.map +1 -1
  48. package/dist/connection/handshake-driver.js.map +1 -1
  49. package/dist/connection/handshake-messages.d.ts +9 -2
  50. package/dist/connection/handshake-messages.d.ts.map +1 -1
  51. package/dist/connection/handshake-messages.js +57 -23
  52. package/dist/connection/handshake-messages.js.map +1 -1
  53. package/dist/errors.d.ts +100 -0
  54. package/dist/errors.d.ts.map +1 -1
  55. package/dist/errors.js +54 -0
  56. package/dist/errors.js.map +1 -1
  57. package/dist/index.d.ts +8 -5
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +5 -3
  60. package/dist/index.js.map +1 -1
  61. package/dist/tls.d.ts +4 -3
  62. package/dist/tls.d.ts.map +1 -1
  63. package/dist/tls.js +4 -3
  64. package/dist/tls.js.map +1 -1
  65. package/dist/types.d.ts +2 -1
  66. package/dist/types.d.ts.map +1 -1
  67. package/dist/types.js +2 -1
  68. package/dist/types.js.map +1 -1
  69. package/package.json +3 -3
@@ -0,0 +1,341 @@
1
+ /**
2
+ * Pure RFC 5280 §6.1 certification-path building and path checks (no I/O).
3
+ *
4
+ * `buildCertificatePath` runs a depth-first search with backtracking from the
5
+ * leaf. At every step the candidates for the current certificate's issuer are
6
+ * tried in order: first the certificate ITSELF as a pinned anchor (identity
7
+ * match, see below), then the trust anchors as issuers, then the remaining
8
+ * server-sent certificates in wire order. A candidate matches when its
9
+ * subject DN equals the current certificate's issuer DN byte-for-byte AND its
10
+ * public key verifies the current certificate's signature; each such
11
+ * verification performed during building IS the chain verification (RFC 5280
12
+ * §6.1.3 (a)), so no pair is ever verified twice.
13
+ *
14
+ * PINNED ANCHORS — matched by identity, never verified: a certificate that is
15
+ * itself an anchor (self-signed, subject DN bytes AND subjectPublicKeyInfo
16
+ * bytes equal to the anchor's) ends the path immediately WITHOUT any
17
+ * signature verification, because there is no issuer edge left to verify —
18
+ * trust rests on the anchor identity, not on the certificate's own signature
19
+ * (old pinned leaves/roots are commonly self-signed with SHA-1 or another
20
+ * rejected algorithm). A NON-self-signed certificate whose ISSUER is an
21
+ * anchor is a real edge and stays signature-verified. A self-signed
22
+ * certificate that merely SHARES the anchor's subject DN but not its SPKI is
23
+ * a name collision: it is not the anchor and has no (real) issuer, so it
24
+ * fails with no-issuer.
25
+ *
26
+ * BACKTRACKING: reaching an anchor completes a candidate path; the path
27
+ * checks below then decide whether it is valid. The FIRST FULLY VALID path
28
+ * (anchored and passing every check) is the result; a candidate whose
29
+ * completed path fails a check is abandoned and the NEXT candidate is tried,
30
+ * so the outcome never depends on the order the server happened to choose
31
+ * (e.g. a cross-signed intermediate sent in a constrained and an unconstrained
32
+ * variant). Termination is unconditional: a certificate is never used twice
33
+ * on one path, and at most {@link MAX_PATH_INTERMEDIATES} intermediates are
34
+ * accepted, so the search visits at most (candidates × path length) states.
35
+ *
36
+ * FAILURE REPORTING: only when every candidate is exhausted is the path
37
+ * reported unanchored, with the failure observed at the DEEPEST search depth —
38
+ * the attempt that got closest to acceptance, where a completed-but-invalid
39
+ * path (anchor edge already added) outranks a dead end at the same prefix —
40
+ * ties resolved by the FIRST attempt recorded at that depth. The message
41
+ * always names the offending certificate.
42
+ *
43
+ * The signature-algorithm policy is deliberately NOT re-checked here — it
44
+ * lives in `validateCertificateChain`'s sweep, which runs in every mode.
45
+ *
46
+ * DN comparison detail: candidate filtering compares the DER byte spans of the
47
+ * candidate's subject and the current certificate's issuer. The signature check
48
+ * is what actually binds issuer to subject — DN equality only selects the
49
+ * candidate set (BoringSSL matches names byte-exactly for the same reason). A
50
+ * false-negative filter (differing encodings of the same DN) yields no-issuer,
51
+ * never a false-accept: nothing is trusted without a verifying signature (or
52
+ * an identity match with a pinned anchor).
53
+ */
54
+ import type { Certificate, CryptoProvider } from "@browsercore/contracts";
55
+ import { type CertificateFailureReason } from "../errors.js";
56
+ import type { GeneralNames } from "./general-names.js";
57
+ import { type NameConstraints } from "./name-constraints.js";
58
+ /**
59
+ * One entry of the ordered extension inventory of a parsed certificate
60
+ * (RFC 5280 §4.1.2.9): the dotted extnID, the critical flag (DEFAULT FALSE per
61
+ * §4.2), and the CONTENTS of the extnValue OCTET STRING. Produced by
62
+ * parseExtensionsBlock; consumed by the critical-extension policy
63
+ * (pathCriticalExtensionsError via extension-policy.ts).
64
+ */
65
+ export interface CertificateExtension {
66
+ /** Dotted extnID OBJECT IDENTIFIER (RFC 5280 §4.1.2.9). */
67
+ readonly oid: string;
68
+ /** critical BOOLEAN, DEFAULT FALSE (RFC 5280 §4.2). */
69
+ readonly critical: boolean;
70
+ /** CONTENTS of the extnValue OCTET STRING (the DER-encoded extension value). */
71
+ readonly value: Uint8Array;
72
+ }
73
+ /**
74
+ * tls-internal parsed certificate: the contract's {@link Certificate} plus the
75
+ * fields path building needs that the contract deliberately does not carry.
76
+ *
77
+ * The DN byte spans are the issuer↔subject comparison key (see the module
78
+ * comment); keyUsage presence and the keyCertSign bit, and the BasicConstraints
79
+ * pathLenConstraint, feed the RFC 5280 §6.1.3 issuer-authorization checks; the
80
+ * extension inventory and the parsed extendedKeyUsage feed the extension-policy
81
+ * checks (RFC 5280 §4.2 criticals, SERVER_AUTH EKU).
82
+ * `parseCertificate` keeps returning the bare contract type at the public
83
+ * boundary — this superset travels only inside the package.
84
+ */
85
+ export interface ParsedCertificate extends Certificate {
86
+ /** DER byte span of the subject Name (candidate-filter key). */
87
+ readonly subjectDn: Uint8Array;
88
+ /** DER byte span of the issuer Name (candidate-filter key). */
89
+ readonly issuerDn: Uint8Array;
90
+ /** True when a keyUsage extension was present at all (RFC 5280 §4.2.1.3). */
91
+ readonly keyUsagePresent: boolean;
92
+ /** True when a present keyUsage extension asserts the keyCertSign bit. */
93
+ readonly keyUsageKeyCertSign: boolean;
94
+ /**
95
+ * BasicConstraints pathLenConstraint (RFC 5280 §4.2.1.9); null when
96
+ * absent. A sign-violating or non-minimal INTEGER is a malformed
97
+ * certificate and throws at parse time (see parsePathLenConstraint).
98
+ */
99
+ readonly pathLenConstraint: number | null;
100
+ /**
101
+ * The ordered extension inventory (RFC 5280 §4.1.2.9) — every extension
102
+ * the certificate carries, in wire order, with its critical flag and raw
103
+ * extnValue contents. The critical-extension policy iterates this list.
104
+ */
105
+ readonly extensions: readonly CertificateExtension[];
106
+ /**
107
+ * True when an extendedKeyUsage extension was present at all (RFC 5280
108
+ * §4.2.1.12). Presence matters independently of the OID list: an EMPTY
109
+ * EKU sequence is "present, permitting nothing" and fails the SERVER_AUTH
110
+ * rule, while an absent extension is accepted (Chrome's kEkuNotPresent
111
+ * warning only).
112
+ */
113
+ readonly extendedKeyUsagePresent: boolean;
114
+ /** The parsed EKU OID list (dotted, in order); empty when the extension is absent or empty. */
115
+ readonly extendedKeyUsage: readonly string[];
116
+ /**
117
+ * The parsed subjectAltName (RFC 5280 §4.2.1.6 GeneralNames) — null when
118
+ * the extension is absent. The name-constraint engine checks these names
119
+ * (BoringSSL IsPermittedCert's subject_alt_names operand); the presence
120
+ * of the EXTENSION (not the count of names) also decides whether the
121
+ * subject's emailAddress attributes fall under rfc822Name constraints.
122
+ */
123
+ readonly sanNames: GeneralNames | null;
124
+ /**
125
+ * The parsed nameConstraints extension (RFC 5280 §4.2.1.10) — null when
126
+ * absent. Its value is parsed for EVERY certificate carrying the
127
+ * extension (a malformed value is a rejected certificate, critical or
128
+ * not — kFailedParsingNameConstraints); its CONSTRAINTS apply to the
129
+ * certificates BELOW it on the path, never to itself.
130
+ */
131
+ readonly nameConstraints: NameConstraints | null;
132
+ /**
133
+ * The subject Name's RDNSequence VALUE bytes (outer SEQUENCE tag
134
+ * stripped) — the DN-matching operand for directoryName constraints and
135
+ * the self-issued test (BoringSSL's normalized_subject() operand, with
136
+ * the per-attribute normalization done inside the matcher).
137
+ */
138
+ readonly subjectNameValue: Uint8Array;
139
+ /** The issuer Name's RDNSequence VALUE bytes (tag stripped) — the self-issued test operand. */
140
+ readonly issuerNameValue: Uint8Array;
141
+ }
142
+ /**
143
+ * The server-sent certificate list: the leaf first, then every following
144
+ * CertificateEntry in wire order. There is deliberately NO `root` field —
145
+ * servers almost always omit the root, and whether the last entry is a root,
146
+ * an intermediate or an unrelated certificate is decided by path building,
147
+ * not by wire position.
148
+ */
149
+ export interface CertificateChain {
150
+ readonly leaf: ParsedCertificate;
151
+ readonly intermediates: readonly ParsedCertificate[];
152
+ }
153
+ /**
154
+ * A trust anchor: a parsed certificate trusted a priori (RFC 5280 §6.1.1).
155
+ * Consumers parse the anchor DER (typically a self-signed root) with
156
+ * `parseCertificateDetails`; its SPKI + subject DN identify it (identity
157
+ * match for a pinned certificate) and its key verifies the top of the path.
158
+ */
159
+ export type TrustAnchor = ParsedCertificate;
160
+ /**
161
+ * Maximum intermediates between the leaf and the anchor. Chrome caps path
162
+ * length the same way; without a limit a degenerate chain (or a hostile
163
+ * server) could make the search walk hundreds of useless entries.
164
+ */
165
+ export declare const MAX_PATH_INTERMEDIATES = 8;
166
+ /**
167
+ * Why building stopped short of a fully valid path: the two search-level
168
+ * failures plus every path-check failure (the builder validates each
169
+ * completed candidate path, so an expired/not-CA/path-too-long intermediate
170
+ * surfaces through the same union). This is {@link CertificateFailureReason}
171
+ * minus "no-anchors", which verifyChain raises before building starts.
172
+ */
173
+ export type CertificatePathFailureReason = Exclude<CertificateFailureReason, "no-anchors">;
174
+ /**
175
+ * The discriminated build result: `anchored` carries the ordered path from the
176
+ * leaf to the certificate that ended it plus the anchor (for an issuer edge
177
+ * the anchor is NOT part of the path — RFC 5280 §6.1 treats it as trusted a
178
+ * priori; for a pinned identity match the anchor IS the path's last
179
+ * certificate). `unanchored` names the failure of the deepest attempted path:
180
+ * `certificate`/`certificateIndex` identify the certificate whose issuer
181
+ * search failed (or that would exceed the limit / whose completed path failed
182
+ * a check), and `message` is the fully rendered diagnostic.
183
+ */
184
+ export type CertificatePath = {
185
+ readonly kind: "anchored";
186
+ readonly path: readonly ParsedCertificate[];
187
+ readonly anchor: TrustAnchor;
188
+ } | {
189
+ readonly kind: "unanchored";
190
+ readonly reason: CertificatePathFailureReason;
191
+ /** Diagnostic for the reported (deepest) failure; names the offender. */
192
+ readonly message: string;
193
+ /** Structured outcome payload of the deepest failure, if it has one. */
194
+ readonly details?: Record<string, unknown> | undefined;
195
+ /** The certificate the failure is attributed to. */
196
+ readonly certificate: ParsedCertificate;
197
+ /** Wire index of `certificate` in the server-sent list (leaf is 0). */
198
+ readonly certificateIndex: number;
199
+ /** DN-matching candidates tried at the failure level whose signature failed. */
200
+ readonly candidateCount: number;
201
+ };
202
+ /**
203
+ * A structured path-check failure: the discriminated reason plus the fully
204
+ * rendered diagnostic (narrowed to the path-check reasons — the cores never
205
+ * produce "no-anchors", which verifyChain raises before building). `details`
206
+ * carries the structured outcome payload where one exists (the name-constraint
207
+ * check puts the discriminated BoringSSL outcome under `nameConstraint`);
208
+ * undefined otherwise. Exported because the extension-policy path checks live
209
+ * beside the other checks here and share the shape with their throwing
210
+ * wrappers.
211
+ */
212
+ export interface PathCheckFailure {
213
+ readonly reason: CertificatePathFailureReason;
214
+ readonly message: string;
215
+ readonly details?: Record<string, unknown> | undefined;
216
+ }
217
+ /**
218
+ * Build the certification path from the leaf to a trust anchor.
219
+ *
220
+ * Depth-first search with backtracking: candidates are tried anchors-first,
221
+ * then server certificates in wire order; the first FULLY VALID path (reaching
222
+ * an anchor and passing every check) wins; exhausted candidates yield an
223
+ * unanchored result carrying the deepest failure (see the module comment).
224
+ * Unanchored results never throw — the caller decides how to surface them.
225
+ */
226
+ export declare function buildCertificatePath(chain: CertificateChain, trustAnchors: readonly TrustAnchor[], provider: CryptoProvider, now: number): CertificatePath;
227
+ /**
228
+ * Validity window for EVERY certificate on the built path (RFC 5280 §6.1.2
229
+ * (a)/(b) + §6.1.3) — including a pinned leaf: the path's certificates come
230
+ * from the wire, and the wire target's validity is checked unconditionally
231
+ * (BoringSSL's verify_certificate_chain does the same for a directly trusted
232
+ * leaf). The trust anchor itself is never part of the built path when it acts
233
+ * as the ISSUER of the top certificate, so its own expiry is never checked
234
+ * (old roots outlive their notAfter all the time); there is deliberately no
235
+ * object-identity shortcut here — whether the pinned match reuses the same
236
+ * parsed object or a second parse of the same DER, the outcome is identical.
237
+ */
238
+ export declare function pathValidityWindowError(path: readonly ParsedCertificate[], now: number): PathCheckFailure | undefined;
239
+ /** Throwing wrapper around {@link pathValidityWindowError} (see it for the WHY). */
240
+ export declare function checkPathValidityWindow(path: readonly ParsedCertificate[], now: number): void;
241
+ /**
242
+ * Issuer-authorization constraints for every intermediate on the built path
243
+ * (RFC 5280 §6.1.3 (k)/(l) + §4.2.1.3): an intermediate must carry
244
+ * basicConstraints cA=TRUE, and when it carries a keyUsage extension, that
245
+ * extension must assert keyCertSign. Absence of the keyUsage EXTENSION is
246
+ * tolerated (RFC 5280 makes it optional); absence of the cA flag is not. The
247
+ * anchor is exempt because it is trusted a priori AND never part of the built
248
+ * path when it acts as the issuer of the top certificate (a legacy root
249
+ * without basicConstraints or keyCertSign must still verify paths under it);
250
+ * a WIRE certificate that merely matches an anchor by DN+SPKI is checked like
251
+ * any other intermediate.
252
+ */
253
+ export declare function pathCaConstraintsError(path: readonly ParsedCertificate[]): PathCheckFailure | undefined;
254
+ /** Throwing wrapper around {@link pathCaConstraintsError} (see it for the WHY). */
255
+ export declare function checkPathCaConstraints(path: readonly ParsedCertificate[]): void;
256
+ /**
257
+ * pathLenConstraint along the built path (RFC 5280 §4.2.1.9): a certificate's
258
+ * constraint bounds the number of NON-self-issued intermediates that may
259
+ * FOLLOW it ("below" it, towards the leaf). Every issuer on the path is
260
+ * checked — each intermediate, and the anchor as issuer of the top
261
+ * intermediate (RFC 5280 §6.1.1 (h) seeds max_path_length from the anchor's
262
+ * constraint; the anchor's own status is a priori trusted, but its constraint
263
+ * is a delegation LIMIT on the certificates below it). RFC 5280 counts
264
+ * non-self-issued certificates only; our `selfSigned` flag (subject DN bytes
265
+ * equal issuer DN bytes) is exactly the subject==issuer test. The counting
266
+ * loop skips `anchor` by POSITION (the certificate in anchor position is the
267
+ * issuer, never one of the intermediates it constrains) — a WIRE certificate
268
+ * that merely matches the anchor by DN+SPKI is counted like any other
269
+ * intermediate, so the outcome does not depend on whether the pinned match
270
+ * reused the same parsed object.
271
+ */
272
+ export declare function pathLengthConstraintsError(path: readonly ParsedCertificate[], anchor: TrustAnchor): PathCheckFailure | undefined;
273
+ /** Throwing wrapper around {@link pathLengthConstraintsError} (see it for the WHY). */
274
+ export declare function checkPathLengthConstraints(path: readonly ParsedCertificate[], anchor: TrustAnchor): void;
275
+ /**
276
+ * nameConstraints enforcement along the built path (RFC 5280 §4.2.1.10,
277
+ * BoringSSL `NameConstraints::IsPermittedCert` driven from
278
+ * verify_certificate_chain.cc): the constraints of every certificate ABOVE a
279
+ * path certificate apply to it — the trust anchor's included, because this
280
+ * verifier's anchors are caller-supplied, exactly Chrome's
281
+ * `additional_trust_anchors_with_constraints` which Chromium's
282
+ * net/cert/cert_verify_proc_builtin.cc arms with
283
+ * `WithEnforceAnchorConstraints` —
284
+ * and NEVER the constraints of the certificate itself (BoringSSL accumulates
285
+ * `name_constraints_list_` in PrepareForNextCertificate and checks the NEXT
286
+ * certificates against it; the root's own name is never checked — "Don't do
287
+ * any other checks for root certificates"). A SELF-ISSUED non-target
288
+ * certificate skips the check ("If certificate i is self-issued and it is
289
+ * not the final certificate in the path, skip this step for certificate i" —
290
+ * verify_certificate_chain.cc:1176-1178; self-issued = normalized subject
291
+ * equals normalized issuer, IsSelfIssued at :132-134).
292
+ *
293
+ * Checking order mirrors BoringSSL's list: the anchor's constraints first
294
+ * (ApplyTrustAnchorConstraints pushes them at the root step), then the
295
+ * intermediates top-down. Runs ONLY from the anchor-supplied path builder —
296
+ * hostname-only mode never sees it.
297
+ */
298
+ export declare function pathNameConstraintsError(path: readonly ParsedCertificate[], anchor: TrustAnchor): PathCheckFailure | undefined;
299
+ /** Throwing wrapper around {@link pathNameConstraintsError} (see it for the WHY). */
300
+ export declare function checkPathNameConstraints(path: readonly ParsedCertificate[], anchor: TrustAnchor): void;
301
+ /**
302
+ * extendedKeyUsage as Chrome 140 enforces it (RFC 5280 §4.2.1.12, BoringSSL
303
+ * `VerifyExtendedKeyUsage` with KeyPurpose::SERVER_AUTH — the value
304
+ * cert_verify_proc_builtin.cc passes for every TLS-server verification): every
305
+ * certificate on the built path that carries an EKU extension must include
306
+ * id-kp-serverAuth (1.3.6.1.5.5.7.3.1) or anyExtendedKeyUsage (2.5.29.37.0);
307
+ * the deciding SERVER_AUTH error is `kEkuLacksServerAuth`, raised by "if
308
+ * (cert.has_extended_key_usage() && !has_server_auth_eku && !has_any_eku)" for
309
+ * the target and for EVERY issuer alike ("Legacy compatible" branch). A
310
+ * MISSING extension is accepted (leaf: only the kEkuNotPresent warning;
311
+ * intermediates: "At this time … some intermediates are lacking EKU in the
312
+ * world at large from common CA's, so we allow the noEKU case to permit
313
+ * everything."), and an EMPTY EKU sequence is present-but-permitting-nothing,
314
+ * so it fails. Code-signing/time-stamping/OCSP-signing EKUs alongside
315
+ * serverAuth are only warnings in this mode (`add_error_if_strict` → warning).
316
+ * The anchor is exempt (see {@link isAnchorOnPath}).
317
+ */
318
+ export declare function pathServerAuthEkuError(path: readonly ParsedCertificate[], anchor: TrustAnchor): PathCheckFailure | undefined;
319
+ /** Throwing wrapper around {@link pathServerAuthEkuError} (see it for the WHY). */
320
+ export declare function checkPathServerAuthEku(path: readonly ParsedCertificate[], anchor: TrustAnchor): void;
321
+ /**
322
+ * Unrecognized critical extensions on the built path (RFC 5280 §4.2: "A
323
+ * certificate-using system MUST reject the certificate if it encounters a
324
+ * critical extension it does not recognize or a critical extension that
325
+ * contains information that it cannot process."), applied exactly like
326
+ * Chrome's built-in verifier: BoringSSL's `VerifyNoUnconsumedCriticalExtensions`
327
+ * runs for the target certificate (WrapUp) and for every intermediate
328
+ * (PrepareForNextCertificate), but NOT for the trust anchor ("Don't do any
329
+ * other checks for root certificates" in the verification loop; the anchor is
330
+ * only checked when trust-anchor CONSTRAINT enforcement is enabled, which
331
+ * Chrome does not do by default) — hence the {@link isAnchorOnPath} exemption.
332
+ * The recognized set is decided by extension-policy.ts
333
+ * ({@link isCriticalExtensionHandled}); nameConstraints (2.5.29.30) is in the
334
+ * recognized set because its constraints are now PROCESSED (see
335
+ * {@link pathNameConstraintsError}) — BoringSSL's IsHandledCriticalExtension
336
+ * accepts it for the same reason.
337
+ */
338
+ export declare function pathCriticalExtensionsError(path: readonly ParsedCertificate[], anchor: TrustAnchor): PathCheckFailure | undefined;
339
+ /** Throwing wrapper around {@link pathCriticalExtensionsError} (see it for the WHY). */
340
+ export declare function checkPathCriticalExtensions(path: readonly ParsedCertificate[], anchor: TrustAnchor): void;
341
+ //# sourceMappingURL=certificate-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"certificate-path.d.ts","sourceRoot":"","sources":["../../src/certificates/certificate-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAuB,KAAK,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAElF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAGH,KAAK,eAAe,EACvB,MAAM,uBAAuB,CAAC;AAa/B;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACjC,2DAA2D;IA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