node-opcua-pki 6.22.0 → 7.0.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.
Files changed (137) hide show
  1. package/bin/install_prerequisite.ts +1 -1
  2. package/bin/pki.ts +1 -1
  3. package/dist/bin/install_prerequisite.d.ts +2 -0
  4. package/dist/bin/install_prerequisite.js +6 -0
  5. package/dist/bin/install_prerequisite.js.map +1 -0
  6. package/dist/bin/pki.d.ts +2 -0
  7. package/dist/bin/pki.js +4 -0
  8. package/dist/bin/pki.js.map +1 -0
  9. package/dist/lib/ca/backends/native_ca_backend.d.ts +49 -0
  10. package/dist/lib/ca/backends/native_ca_backend.js +365 -0
  11. package/dist/lib/ca/backends/native_ca_backend.js.map +1 -0
  12. package/dist/lib/ca/backends/openssl_ca_backend.d.ts +47 -0
  13. package/dist/lib/ca/backends/openssl_ca_backend.js +398 -0
  14. package/dist/lib/ca/backends/openssl_ca_backend.js.map +1 -0
  15. package/dist/lib/ca/certificate_authority.d.ts +62 -0
  16. package/dist/lib/ca/certificate_authority.js +91 -0
  17. package/dist/lib/ca/certificate_authority.js.map +1 -0
  18. package/dist/lib/ca/core/ca_backend.d.ts +89 -0
  19. package/dist/lib/ca/core/ca_backend.js +24 -0
  20. package/dist/lib/ca/core/ca_backend.js.map +1 -0
  21. package/dist/lib/ca/core/ca_database.d.ts +91 -0
  22. package/dist/lib/ca/core/ca_database.js +267 -0
  23. package/dist/lib/ca/core/ca_database.js.map +1 -0
  24. package/dist/{core-BwqSJPHc.d.mts → lib/ca/core/certificate_authority_core.d.ts} +45 -394
  25. package/dist/lib/ca/core/certificate_authority_core.js +1300 -0
  26. package/dist/lib/ca/core/certificate_authority_core.js.map +1 -0
  27. package/dist/lib/ca/core/index.d.ts +17 -0
  28. package/dist/lib/ca/core/index.js +25 -0
  29. package/dist/lib/ca/core/index.js.map +1 -0
  30. package/dist/lib/ca/crypto_create_CA.d.ts +1 -0
  31. package/dist/lib/ca/crypto_create_CA.js +821 -0
  32. package/dist/lib/ca/crypto_create_CA.js.map +1 -0
  33. package/dist/lib/ca/index.d.ts +1 -0
  34. package/dist/lib/ca/index.js +2 -0
  35. package/dist/lib/ca/index.js.map +1 -0
  36. package/dist/lib/ca/templates/ca_config_template.cnf.d.ts +2 -0
  37. package/dist/lib/ca/templates/ca_config_template.cnf.js +170 -0
  38. package/dist/lib/ca/templates/ca_config_template.cnf.js.map +1 -0
  39. package/dist/lib/core.d.ts +33 -0
  40. package/dist/lib/core.js +56 -0
  41. package/dist/lib/core.js.map +1 -0
  42. package/dist/lib/index.d.ts +11 -0
  43. package/dist/lib/index.js +37 -0
  44. package/dist/lib/index.js.map +1 -0
  45. package/dist/lib/misc/applicationurn.d.ts +1 -0
  46. package/dist/lib/misc/applicationurn.js +40 -0
  47. package/dist/lib/misc/applicationurn.js.map +1 -0
  48. package/dist/lib/misc/hostname.d.ts +8 -0
  49. package/dist/lib/misc/hostname.js +82 -0
  50. package/dist/lib/misc/hostname.js.map +1 -0
  51. package/dist/lib/misc/subject.d.ts +2 -0
  52. package/dist/lib/misc/subject.js +2 -0
  53. package/dist/lib/misc/subject.js.map +1 -0
  54. package/dist/{index.d.ts → lib/pki/certificate_manager.d.ts} +24 -246
  55. package/dist/lib/pki/certificate_manager.js +2302 -0
  56. package/dist/lib/pki/certificate_manager.js.map +1 -0
  57. package/dist/lib/pki/templates/simple_config_template.cnf.d.ts +2 -0
  58. package/dist/lib/pki/templates/simple_config_template.cnf.js +74 -0
  59. package/dist/lib/pki/templates/simple_config_template.cnf.js.map +1 -0
  60. package/dist/lib/pki/toolbox_pfx.d.ts +127 -0
  61. package/dist/lib/pki/toolbox_pfx.js +248 -0
  62. package/dist/lib/pki/toolbox_pfx.js.map +1 -0
  63. package/dist/lib/toolbox/common.d.ts +150 -0
  64. package/dist/lib/toolbox/common.js +82 -0
  65. package/dist/lib/toolbox/common.js.map +1 -0
  66. package/dist/lib/toolbox/common2.d.ts +25 -0
  67. package/dist/lib/toolbox/common2.js +97 -0
  68. package/dist/lib/toolbox/common2.js.map +1 -0
  69. package/dist/lib/toolbox/config.d.ts +5 -0
  70. package/dist/lib/toolbox/config.js +28 -0
  71. package/dist/lib/toolbox/config.js.map +1 -0
  72. package/dist/lib/toolbox/debug.d.ts +5 -0
  73. package/dist/lib/toolbox/debug.js +35 -0
  74. package/dist/lib/toolbox/debug.js.map +1 -0
  75. package/dist/lib/toolbox/display.d.ts +4 -0
  76. package/dist/lib/toolbox/display.js +56 -0
  77. package/dist/lib/toolbox/display.js.map +1 -0
  78. package/dist/lib/toolbox/index.d.ts +5 -0
  79. package/dist/lib/toolbox/index.js +28 -0
  80. package/dist/lib/toolbox/index.js.map +1 -0
  81. package/dist/lib/toolbox/with_openssl/_create_random_file.d.ts +4 -0
  82. package/dist/lib/toolbox/with_openssl/_create_random_file.js +50 -0
  83. package/dist/lib/toolbox/with_openssl/_create_random_file.js.map +1 -0
  84. package/dist/lib/toolbox/with_openssl/_env.d.ts +58 -0
  85. package/dist/lib/toolbox/with_openssl/_env.js +126 -0
  86. package/dist/lib/toolbox/with_openssl/_env.js.map +1 -0
  87. package/dist/lib/toolbox/with_openssl/create_certificate_signing_request.d.ts +5 -0
  88. package/dist/lib/toolbox/with_openssl/create_certificate_signing_request.js +72 -0
  89. package/dist/lib/toolbox/with_openssl/create_certificate_signing_request.js.map +1 -0
  90. package/dist/lib/toolbox/with_openssl/create_private_key.d.ts +5 -0
  91. package/dist/lib/toolbox/with_openssl/create_private_key.js +92 -0
  92. package/dist/lib/toolbox/with_openssl/create_private_key.js.map +1 -0
  93. package/dist/lib/toolbox/with_openssl/create_self_signed_certificate.d.ts +5 -0
  94. package/dist/lib/toolbox/with_openssl/create_self_signed_certificate.js +135 -0
  95. package/dist/lib/toolbox/with_openssl/create_self_signed_certificate.js.map +1 -0
  96. package/dist/lib/toolbox/with_openssl/execute_openssl.d.ts +67 -0
  97. package/dist/lib/toolbox/with_openssl/execute_openssl.js +246 -0
  98. package/dist/lib/toolbox/with_openssl/execute_openssl.js.map +1 -0
  99. package/dist/lib/toolbox/with_openssl/index.d.ts +5 -0
  100. package/dist/lib/toolbox/with_openssl/index.js +30 -0
  101. package/dist/lib/toolbox/with_openssl/index.js.map +1 -0
  102. package/dist/lib/toolbox/with_openssl/install_prerequisite.d.ts +7 -0
  103. package/dist/lib/toolbox/with_openssl/install_prerequisite.js +358 -0
  104. package/dist/lib/toolbox/with_openssl/install_prerequisite.js.map +1 -0
  105. package/dist/lib/toolbox/with_openssl/toolbox.d.ts +53 -0
  106. package/dist/lib/toolbox/with_openssl/toolbox.js +190 -0
  107. package/dist/lib/toolbox/with_openssl/toolbox.js.map +1 -0
  108. package/dist/lib/toolbox/without_openssl/create_certificate_signing_request.d.ts +5 -0
  109. package/dist/lib/toolbox/without_openssl/create_certificate_signing_request.js +69 -0
  110. package/dist/lib/toolbox/without_openssl/create_certificate_signing_request.js.map +1 -0
  111. package/dist/lib/toolbox/without_openssl/create_self_signed_certificate.d.ts +3 -0
  112. package/dist/lib/toolbox/without_openssl/create_self_signed_certificate.js +78 -0
  113. package/dist/lib/toolbox/without_openssl/create_self_signed_certificate.js.map +1 -0
  114. package/dist/lib/toolbox/without_openssl/index.d.ts +2 -0
  115. package/dist/lib/toolbox/without_openssl/index.js +25 -0
  116. package/dist/lib/toolbox/without_openssl/index.js.map +1 -0
  117. package/package.json +11 -30
  118. package/dist/bin/install_prerequisite.mjs +0 -18
  119. package/dist/bin/install_prerequisite.mjs.map +0 -1
  120. package/dist/bin/pki.mjs +0 -5895
  121. package/dist/bin/pki.mjs.map +0 -1
  122. package/dist/chunk-EQ4DGI4M.mjs +0 -1917
  123. package/dist/chunk-EQ4DGI4M.mjs.map +0 -1
  124. package/dist/chunk-GCHH54PS.mjs +0 -30
  125. package/dist/chunk-GCHH54PS.mjs.map +0 -1
  126. package/dist/core-BwqSJPHc.d.ts +0 -1041
  127. package/dist/core.d.mts +0 -2
  128. package/dist/core.d.ts +0 -2
  129. package/dist/core.js +0 -1902
  130. package/dist/core.js.map +0 -1
  131. package/dist/core.mjs +0 -21
  132. package/dist/core.mjs.map +0 -1
  133. package/dist/index.d.mts +0 -1001
  134. package/dist/index.js +0 -4968
  135. package/dist/index.js.map +0 -1
  136. package/dist/index.mjs +0 -3106
  137. package/dist/index.mjs.map +0 -1
package/dist/index.d.mts DELETED
@@ -1,1001 +0,0 @@
1
- import { IKeyOperations, PrivateKey, Certificate, SubjectOptions, DER, CertificateRevocationList } from 'node-opcua-crypto';
2
- export { AsymmetricDecryptParams, AsymmetricSignParams, IKeyOperations, KeyMetadata, PrivateKeyPassphraseRequiredError, PrivateKeyUnavailableError, Subject, SubjectOptions } from 'node-opcua-crypto';
3
- import { C as CaBackend, a as CertificateAuthorityCore, P as Params, b as ProcessAltNamesParam, c as CertificateAuthorityCoreOptions, K as KeySize, d as PrivateKeyPassphrase, e as PrivateKeyProvider, f as CreateSelfSignCertificateParam, F as Filename } from './core-BwqSJPHc.mjs';
4
- export { g as CertificateStatus, h as CreateCertificateSigningRequestOptions, i as CreateCertificateSigningRequestWithConfigOptions, j as CreateSelfSignCertificateWithConfigParam, G as GenerateKeyPairAndSignOptions, k as GenerateKeyPairAndSignPFXOptions, I as InitializeCSRResult, l as InstallCACertificateResult, m as KeyLength, N as NativeCaBackend, n as PkiBackendCapabilities, S as SignCertificateOptions, o as StartDateEndDateParam, T as Thumbprint, p as adjustApplicationUri, q as adjustDate, r as isOpaqueSigner, s as quote, t as resolvePrivateKeyPassphrase } from './core-BwqSJPHc.mjs';
5
- import { EventEmitter } from 'node:events';
6
-
7
- /**
8
- * The default {@link CaBackend}: shells out to the `openssl` CLI, exactly as
9
- * `CertificateAuthority` always has — this is a pure code move (plus a lock
10
- * around every database-mutating operation, temp-config cleanup, and
11
- * explicit `envOverrides` on every config render) with no change in the
12
- * openssl commands issued or the files produced.
13
- */
14
- declare class OpenSslCaBackend implements CaBackend {
15
- #private;
16
- /** The openssl CLI loads its key from a file, so it cannot call out to an HSM. */
17
- readonly supportsExternalSigner = false;
18
- preflight(): Promise<void>;
19
- generateCaCsr(ca: CertificateAuthorityCore, _caRootDir: string, privateKeyFile: string, csrFile: string): Promise<void>;
20
- bootstrap(ca: CertificateAuthorityCore): Promise<void>;
21
- regenerateCrl(ca: CertificateAuthorityCore): Promise<void>;
22
- signSubordinateCsr(ca: CertificateAuthorityCore, csrFile: string, certFile: string, validityDays: number): Promise<void>;
23
- signEndEntityCsr(ca: CertificateAuthorityCore, certificate: string, csr: string, params1: Params, sanOverride: Required<ProcessAltNamesParam>): Promise<void>;
24
- revoke(ca: CertificateAuthorityCore, certificate: string, reason: string): Promise<void>;
25
- createSelfSignedCertificate(ca: CertificateAuthorityCore, certificateFile: string, privateKeyFile: string, params: Params): Promise<void>;
26
- }
27
-
28
- /** openssl argv entries plus the env they need; merge `env` into `ExecuteOptions.env`. */
29
- interface OpensslPassArg {
30
- args: string[];
31
- env: NodeJS.ProcessEnv;
32
- }
33
-
34
- /**
35
- *
36
- * return path to the openssl executable
37
- */
38
- declare function install_prerequisite(): Promise<string>;
39
-
40
- /**
41
- * Options for {@link CertificateAuthority}: the core's, except that the
42
- * backend is named rather than supplied.
43
- */
44
- interface CertificateAuthorityOptions extends Omit<CertificateAuthorityCoreOptions, "backend"> {
45
- /**
46
- * Signing backend to use.
47
- *
48
- * - `"openssl"` (default): shells out to the `openssl` CLI, as this
49
- * class always has.
50
- * - `"native"`: signs in pure JS via `node-opcua-crypto`, writing the
51
- * same on-disk database format, and needs no `openssl` executable.
52
- *
53
- * Setting `signer` implies `"native"`, since the openssl CLI can only
54
- * load a key from a file.
55
- *
56
- * To supply a backend instance directly - including one of your own -
57
- * use {@link CertificateAuthorityCore}, which is also the class to
58
- * build against when you do not want the openssl backend in your
59
- * bundle at all.
60
- */
61
- backend?: "openssl" | "native";
62
- }
63
- /**
64
- * A Certificate Authority with a backend chosen for you.
65
- *
66
- * This is {@link CertificateAuthorityCore} plus the convenience that made
67
- * it the historical API: name a backend, or name nothing and get openssl.
68
- * Because it resolves the name, it necessarily references both backends,
69
- * which is why the core exists separately - a program that never imports
70
- * this class never pulls the openssl backend into its bundle.
71
- */
72
- declare class CertificateAuthority extends CertificateAuthorityCore {
73
- constructor(options: CertificateAuthorityOptions);
74
- /**
75
- * @internal `-passin env:` argv + env for an openssl call that loads
76
- * this CA's key (always emitted, empty when none).
77
- *
78
- * The openssl backend builds its own now; this remains so that external
79
- * code calling it keeps working, and lives here rather than on the core
80
- * because the flag means nothing to a backend that spawns nothing.
81
- */
82
- _opensslPassin(): Promise<OpensslPassArg>;
83
- /**
84
- * @internal
85
- * Legacy shim: publish the `CDP_URL` / `AIA_VALUE` config substitution
86
- * values to the shared env registry, or unset them so the matching
87
- * `{{#KEY}}...{{/KEY}}` blocks are stripped. Nothing in this package
88
- * reads the registry any more - every openssl config render receives
89
- * these values explicitly, from the same {@link caConfigEnvOverrides}
90
- * builder this delegates to, so the two cannot drift - kept only for
91
- * external code that renders openssl config templates against the
92
- * registry directly.
93
- *
94
- * It lives on this class rather than the core because it is meaningful
95
- * only to the openssl backend.
96
- */
97
- _wireRevocationEnvVars(): void;
98
- }
99
-
100
- /**
101
- * Identifies which PKI sub-store a certificate event originated from.
102
- */
103
- type CertificateStore = "trusted" | "rejected" | "issuersCerts";
104
- /**
105
- * Identifies which PKI sub-store a CRL event originated from.
106
- */
107
- type CrlStore = "crl" | "issuersCrl";
108
- /**
109
- * Events emitted by {@link CertificateManager} when the
110
- * file-system watchers detect certificate or CRL changes.
111
- */
112
- interface CertificateManagerEvents {
113
- /** A certificate file was added to a store. */
114
- certificateAdded: (event: {
115
- store: CertificateStore;
116
- certificate: Certificate;
117
- fingerprint: string;
118
- filename: string;
119
- }) => void;
120
- /** A certificate file was removed from a store. */
121
- certificateRemoved: (event: {
122
- store: CertificateStore;
123
- fingerprint: string;
124
- filename: string;
125
- }) => void;
126
- /** A certificate file was modified in a store. */
127
- certificateChange: (event: {
128
- store: CertificateStore;
129
- certificate: Certificate;
130
- fingerprint: string;
131
- filename: string;
132
- }) => void;
133
- /** A CRL file was added. */
134
- crlAdded: (event: {
135
- store: CrlStore;
136
- filename: string;
137
- }) => void;
138
- /** A CRL file was removed. */
139
- crlRemoved: (event: {
140
- store: CrlStore;
141
- filename: string;
142
- }) => void;
143
- }
144
- /**
145
- * Options controlling certificate validation in
146
- * {@link CertificateManager.addTrustedCertificateFromChain}.
147
- *
148
- * By default all checks are **strict** (secure). Set individual
149
- * flags to `true` only in test/development environments.
150
- */
151
- interface AddCertificateValidationOptions {
152
- /**
153
- * Accept certificates whose validity period has expired
154
- * or is not yet active.
155
- * @defaultValue false
156
- */
157
- acceptExpiredCertificate?: boolean;
158
- /**
159
- * Accept certificates that have been revoked by their
160
- * issuer's CRL. When `false` (the default), a revoked
161
- * certificate is rejected with `BadCertificateRevoked`.
162
- * @defaultValue false
163
- */
164
- acceptRevokedCertificate?: boolean;
165
- /**
166
- * Do not fail when a CRL is missing for an issuer in the
167
- * chain. When `false` (the default), a missing CRL causes
168
- * `BadCertificateRevocationUnknown`.
169
- * @defaultValue false
170
- */
171
- ignoreMissingRevocationList?: boolean;
172
- /**
173
- * Maximum depth of the certificate chain (leaf + issuers).
174
- * The leaf certificate counts as depth 1.
175
- * @defaultValue 5
176
- */
177
- maxChainLength?: number;
178
- }
179
- /**
180
- * Options for creating a {@link CertificateManager}.
181
- */
182
- interface CertificateManagerOptions {
183
- /**
184
- * RSA key size for generated private keys.
185
- * @defaultValue 2048
186
- */
187
- keySize?: KeySize;
188
- /** Filesystem path where the PKI directory structure is stored. */
189
- location: string;
190
- /**
191
- * Validation options applied by
192
- * {@link CertificateManager.addTrustedCertificateFromChain}.
193
- *
194
- * Defaults are secure — all checks enabled.
195
- */
196
- addCertificateValidationOptions?: AddCertificateValidationOptions;
197
- /**
198
- * When `true`, the CertificateManager will **not** start
199
- * chokidar file-system watchers on the PKI folders.
200
- *
201
- * The initial file-system scan still runs so the in-memory
202
- * indexes are populated, but live change detection is
203
- * disabled. This is useful in test / CI environments where
204
- * many CertificateManager instances are created in parallel
205
- * and the accumulated `fs.watch` handles exhaust the libuv
206
- * thread-pool, causing event-loop starvation.
207
- *
208
- * @defaultValue false
209
- */
210
- disableFileWatchers?: boolean;
211
- /**
212
- * Encrypt the private key at rest with this passphrase (opt-in,
213
- * default off). When set:
214
- * - a freshly generated key is written as encrypted PKCS#8;
215
- * - an existing *plaintext* key is re-encrypted in place by
216
- * {@link CertificateManager.initialize} (atomic rename, same as
217
- * {@link CertificateManager.reencryptPrivateKey}), so enabling the
218
- * option on an existing install never leaves the key in cleartext;
219
- * - an existing encrypted key requires the same passphrase — a
220
- * mismatch, or an encrypted key with no passphrase configured, fails
221
- * `initialize()` closed with `PrivateKeyPassphraseRequiredError`.
222
- *
223
- * A function is called at most once per `CertificateManager` instance
224
- * (the decrypted key is cached in memory for the instance's lifetime,
225
- * see {@link CertificateManager.getPrivateKey}). Never logged.
226
- *
227
- * Existing consumers that read `own/private/private_key.pem` directly
228
- * (e.g. node-opcua's `OPCUAServer`, or `createPFX` without its
229
- * `privateKeyPassphrase` option) still expect a plaintext key — do not
230
- * enable this unless every reader of that file goes through
231
- * {@link CertificateManager.getPrivateKey} or is given the passphrase.
232
- */
233
- privateKeyPassphrase?: PrivateKeyPassphrase;
234
- /**
235
- * Source the private key from somewhere other than
236
- * `own/private/private_key.pem` (an HSM, a KMS, ...). When set, it
237
- * overrides disk entirely for every operation that needs the private
238
- * key — the on-disk file is not read, and `privateKeyPassphrase` is
239
- * ignored.
240
- */
241
- privateKeyProvider?: PrivateKeyProvider;
242
- /**
243
- * Use a private key this manager can never read: an opaque
244
- * {@link IKeyOperations} provider (HSM, KMS, TPM, OS keystore, ...).
245
- *
246
- * The distinction with `privateKeyProvider` matters: a
247
- * `privateKeyProvider` *sources raw key material* from elsewhere and
248
- * hands it back; `keyOperations` never reveals the key — only sign and
249
- * decrypt operations on it. Prefer `keyOperations` whenever the key
250
- * does not need to be exportable.
251
- *
252
- * When set:
253
- * - {@link CertificateManager.getPrivateKey} and
254
- * {@link CertificateManager.reencryptPrivateKey} throw
255
- * `PrivateKeyUnavailableError` — there is no key material to return
256
- * or rewrite, and no on-disk key is generated or expected;
257
- * - {@link CertificateManager.getKeyOperations} returns this object;
258
- * - `initialize()` fails closed if the provider cannot answer
259
- * `getKeyMetadata()` (unreachable HSM, misconfiguration);
260
- * - mutually exclusive with `privateKeyProvider` and
261
- * `privateKeyPassphrase` — both describe key *material*, which an
262
- * opaque configuration does not have.
263
- */
264
- keyOperations?: IKeyOperations;
265
- }
266
- /**
267
- * Parameters for {@link createSelfSignedCertificate}.
268
- * All fields from {@link CreateSelfSignCertificateParam} are required.
269
- */
270
- interface CreateSelfSignCertificateParam1 extends CreateSelfSignCertificateParam {
271
- /**
272
- * Output path for the certificate.
273
- * @defaultValue `"own/certs/self_signed_certificate.pem"`
274
- */
275
- outputFile?: Filename;
276
- /** X.500 subject for the certificate. */
277
- subject: SubjectOptions | string;
278
- /** OPC UA application URI for the SAN extension. */
279
- applicationUri: string;
280
- /** DNS host names to include in the SAN extension. */
281
- dns: string[];
282
- /** Certificate "Not Before" date. */
283
- startDate: Date;
284
- /** Number of days the certificate is valid. */
285
- validity: number;
286
- }
287
- /**
288
- * Options to fine-tune certificate verification behaviour.
289
- * Passed to {@link CertificateManager.verifyCertificate}.
290
- *
291
- * Without any options, `verifyCertificate` is **strict**: only
292
- * certificates that are explicitly present in the trusted store
293
- * will return {@link VerificationStatus.Good}. Unknown or
294
- * rejected certificates return
295
- * {@link VerificationStatus.BadCertificateUntrusted} even when
296
- * their issuer chain is valid.
297
- *
298
- * Set {@link acceptCertificateWithValidIssuerChain} to `true`
299
- * to accept certificates whose issuer chain validates against
300
- * a trusted CA — even if the leaf certificate itself is not
301
- * in the trusted store.
302
- */
303
- interface VerifyCertificateOptions {
304
- /** Accept certificates whose "Not After" date has passed. */
305
- acceptOutdatedCertificate?: boolean;
306
- /** Accept issuer certificates whose "Not After" date has passed. */
307
- acceptOutDatedIssuerCertificate?: boolean;
308
- /** Do not fail when a CRL is missing for an issuer. */
309
- ignoreMissingRevocationList?: boolean;
310
- /** Accept certificates whose "Not Before" date is in the future. */
311
- acceptPendingCertificate?: boolean;
312
- /**
313
- * Accept a certificate that is not in the trusted store when
314
- * its issuer (CA) certificate is trusted, the signature is
315
- * valid, and the certificate does not appear in the CRL.
316
- *
317
- * When `false` (the default), only certificates explicitly
318
- * placed in the trusted store are accepted — this is the
319
- * same behaviour as {@link CertificateManager.isCertificateTrusted}.
320
- *
321
- * @defaultValue false
322
- */
323
- acceptCertificateWithValidIssuerChain?: boolean;
324
- }
325
- /**
326
- * OPC UA certificate verification status codes.
327
- *
328
- * These mirror the OPC UA `StatusCode` values for certificate
329
- * validation results.
330
- */
331
- declare enum VerificationStatus {
332
- /** The certificate provided as a parameter is not valid. */
333
- BadCertificateInvalid = "BadCertificateInvalid",
334
- /** An error occurred verifying security. */
335
- BadSecurityChecksFailed = "BadSecurityChecksFailed",
336
- /** The certificate does not meet the requirements of the security policy. */
337
- BadCertificatePolicyCheckFailed = "BadCertificatePolicyCheckFailed",
338
- /** The certificate has expired or is not yet valid. */
339
- BadCertificateTimeInvalid = "BadCertificateTimeInvalid",
340
- /** An issuer certificate has expired or is not yet valid. */
341
- BadCertificateIssuerTimeInvalid = "BadCertificateIssuerTimeInvalid",
342
- /** The HostName used to connect to a server does not match a HostName in the certificate. */
343
- BadCertificateHostNameInvalid = "BadCertificateHostNameInvalid",
344
- /** The URI specified in the ApplicationDescription does not match the URI in the certificate. */
345
- BadCertificateUriInvalid = "BadCertificateUriInvalid",
346
- /** The certificate may not be used for the requested operation. */
347
- BadCertificateUseNotAllowed = "BadCertificateUseNotAllowed",
348
- /** The issuer certificate may not be used for the requested operation. */
349
- BadCertificateIssuerUseNotAllowed = "BadCertificateIssuerUseNotAllowed",
350
- /** The certificate is not trusted. */
351
- BadCertificateUntrusted = "BadCertificateUntrusted",
352
- /** It was not possible to determine if the certificate has been revoked. */
353
- BadCertificateRevocationUnknown = "BadCertificateRevocationUnknown",
354
- /** It was not possible to determine if the issuer certificate has been revoked. */
355
- BadCertificateIssuerRevocationUnknown = "BadCertificateIssuerRevocationUnknown",
356
- /** The certificate has been revoked. */
357
- BadCertificateRevoked = "BadCertificateRevoked",
358
- /** The issuer certificate has been revoked. */
359
- BadCertificateIssuerRevoked = "BadCertificateIssuerRevoked",
360
- /** The certificate chain is incomplete. */
361
- BadCertificateChainIncomplete = "BadCertificateChainIncomplete",
362
- /** Validation OK. */
363
- Good = "Good"
364
- }
365
- declare function coerceCertificateChain(certificate: Certificate | Certificate[]): Certificate[];
366
- declare function makeFingerprint(certificate: Certificate | Certificate[] | CertificateRevocationList): string;
367
- /**
368
- * Check if the provided certificate acts as an issuer (CA)
369
- * @param certificate - the DER-encoded certificate
370
- * @returns true if the certificate has CA basicConstraints or keyCertSign keyUsage
371
- */
372
- declare function isIssuer(certificate: Certificate): boolean;
373
- /**
374
- * Check if the provided certificate acts as an intermediate issuer.
375
- * An intermediate issuer is a CA certificate that is not a root CA (not self-signed).
376
- * @param certificate - the DER-encoded certificate
377
- * @returns true if the certificate is a CA and is not self-signed
378
- */
379
- declare function isIntermediateIssuer(certificate: Certificate): boolean;
380
- /**
381
- * Check if the provided certificate acts as a root issuer.
382
- * A root issuer is a CA certificate that is self-signed.
383
- * @param certificate - the DER-encoded certificate
384
- * @returns true if the certificate is a CA and is self-signed
385
- */
386
- declare function isRootIssuer(certificate: Certificate): boolean;
387
- /**
388
- * Find the issuer certificate for a given certificate within
389
- * a provided certificate chain.
390
- *
391
- * @param certificate - the DER-encoded certificate whose issuer to find
392
- * @param chain - candidate issuer certificates to search
393
- * @returns the matching issuer certificate, or `null` if not found
394
- */
395
- declare function findIssuerCertificateInChain(certificate: Certificate | Certificate[], chain: Certificate[]): Certificate | null;
396
- /**
397
- * Lifecycle state of a {@link CertificateManager} instance.
398
- */
399
- declare enum CertificateManagerState {
400
- Uninitialized = 0,
401
- Initializing = 1,
402
- Initialized = 2,
403
- Disposing = 3,
404
- Disposed = 4
405
- }
406
- /**
407
- * Manages a GDS-compliant PKI directory structure for an OPC UA
408
- * application.
409
- *
410
- * The PKI store layout follows the OPC UA specification:
411
- *
412
- * ```
413
- * <location>/
414
- * ├── own/
415
- * │ ├── certs/ Own certificate(s)
416
- * │ └── private/ Own private key
417
- * ├── trusted/
418
- * │ ├── certs/ Trusted peer certificates
419
- * │ └── crl/ CRLs for trusted certs
420
- * ├── rejected/ Untrusted / rejected certificates
421
- * └── issuers/
422
- * ├── certs/ CA (issuer) certificates
423
- * └── crl/ CRLs for issuer certificates
424
- * ```
425
- *
426
- * File-system watchers keep the in-memory indexes in sync with
427
- * on-disk changes. Call {@link dispose} when the instance is no
428
- * longer needed to release watchers and allow the process to
429
- * exit cleanly.
430
- *
431
- * ## Environment Variables
432
- *
433
- * - **`OPCUA_PKI_USE_POLLING`** — set to `"true"` to use
434
- * polling-based file watching instead of native OS events.
435
- * Useful for NFS, CIFS, Docker volumes, or other remote /
436
- * virtual file systems where native events are unreliable.
437
- *
438
- * - **`OPCUA_PKI_POLLING_INTERVAL`** — polling interval in
439
- * milliseconds (only effective when polling is enabled).
440
- * Clamped to the range [100, 600 000]. Defaults to
441
- * {@link folderPollingInterval} (5 000 ms).
442
- *
443
- * @example
444
- * ```ts
445
- * const cm = new CertificateManager({ location: "/var/pki" });
446
- * await cm.initialize();
447
- * const status = await cm.verifyCertificate(cert);
448
- * await cm.dispose();
449
- * ```
450
- */
451
- /**
452
- * Status codes returned by {@link CertificateManager.completeCertificateChain}.
453
- */
454
- declare enum ChainCompletionStatus {
455
- /** The chain already reached a self-signed root — no action was needed. */
456
- AlreadyComplete = "AlreadyComplete",
457
- /** One or more issuer certificates were successfully appended. */
458
- ChainCompleted = "ChainCompleted",
459
- /** The issuer for the last certificate in the chain could not be found
460
- * in the issuers or trusted stores. The chain is still partial. */
461
- IssuerNotFound = "IssuerNotFound",
462
- /** The input chain was empty. */
463
- EmptyChain = "EmptyChain",
464
- /** Chain completion was stopped because the maximum depth was reached. */
465
- MaxDepthReached = "MaxDepthReached"
466
- }
467
- /**
468
- * Result of {@link CertificateManager.completeCertificateChain}.
469
- */
470
- interface ChainCompletionResult {
471
- /** The (possibly completed) certificate chain, leaf first. */
472
- chain: Certificate[];
473
- /** Status code indicating whether completion succeeded and why/why not. */
474
- status: ChainCompletionStatus;
475
- /** Human-readable diagnostic message. */
476
- message: string;
477
- }
478
- declare class CertificateManager extends EventEmitter {
479
- #private;
480
- /**
481
- * Dispose **all** active CertificateManager instances,
482
- * closing their file watchers and freeing resources.
483
- *
484
- * This is mainly useful in test tear-down to ensure the
485
- * Node.js process can exit cleanly.
486
- */
487
- static disposeAll(): Promise<void>;
488
- /**
489
- * Assert that all CertificateManager instances have been
490
- * properly disposed. Throws an Error listing the locations
491
- * of any leaked instances.
492
- *
493
- * Intended for use in test `afterAll()` / `afterEach()`
494
- * hooks to catch missing `dispose()` calls early.
495
- *
496
- * @example
497
- * ```ts
498
- * after(() => {
499
- * CertificateManager.checkAllDisposed();
500
- * });
501
- * ```
502
- */
503
- static checkAllDisposed(): void;
504
- /**
505
- * When `true` (the default), any certificate that is not
506
- * already in the trusted or rejected store is automatically
507
- * written to the rejected folder the first time it is seen.
508
- */
509
- untrustUnknownCertificate: boolean;
510
- /** Current lifecycle state of this instance. */
511
- state: CertificateManagerState;
512
- /** @deprecated Use {@link folderPollingInterval} instead (typo fix). */
513
- folderPoolingInterval: number;
514
- /** Interval in milliseconds for file-system polling (when enabled). */
515
- get folderPollingInterval(): number;
516
- set folderPollingInterval(value: number);
517
- /** RSA key size used when generating the private key. */
518
- readonly keySize: KeySize;
519
- /**
520
- * Create a new CertificateManager.
521
- *
522
- * The constructor creates the root directory if it does not
523
- * exist but does **not** initialise the PKI store — call
524
- * {@link initialize} before using any other method.
525
- *
526
- * @param options - configuration options
527
- */
528
- constructor(options: CertificateManagerOptions);
529
- /** Path to the OpenSSL configuration file. */
530
- get configFile(): string;
531
- /** Root directory of the PKI store. */
532
- get rootDir(): string;
533
- /**
534
- * Path to the private key file (`own/private/private_key.pem`).
535
- *
536
- * Kept for backward compatibility with code that reads the key
537
- * directly from disk. When a passphrase or a `privateKeyProvider` is
538
- * configured, prefer {@link getPrivateKey} instead — this getter still
539
- * returns the on-disk path even if a provider is configured (there may
540
- * be no meaningful file in that case).
541
- */
542
- get privateKey(): string;
543
- /**
544
- * Resolve the private key: from `privateKeyProvider` if configured,
545
- * otherwise from disk (decrypting with `privateKeyPassphrase` if the
546
- * key is encrypted). Fails closed — throws
547
- * `PrivateKeyPassphraseRequiredError` — if the on-disk key is encrypted
548
- * and no passphrase is configured, or if the wrong passphrase is
549
- * configured.
550
- *
551
- * The on-disk key is read and decrypted once and then cached for the
552
- * lifetime of this instance, so a `privateKeyPassphrase` function is
553
- * called at most once (concurrent first calls share the same read). A
554
- * failed read is not cached, so a caller can fix the passphrase and
555
- * retry. A `privateKeyProvider` is consulted on every call: it is the
556
- * authority on what the current key is.
557
- */
558
- getPrivateKey(): Promise<PrivateKey>;
559
- /**
560
- * True when this manager's key is opaque — configured through
561
- * `keyOperations`, held by an HSM/KMS, never obtainable as material.
562
- * When true, {@link getPrivateKey} throws `PrivateKeyUnavailableError`
563
- * and {@link getKeyOperations} is the only way to use the key.
564
- */
565
- isPrivateKeyOpaque(): boolean;
566
- /**
567
- * The key as an opaque {@link IKeyOperations} — the recommended way to
568
- * *use* the private key regardless of where it lives.
569
- *
570
- * Returns the configured `keyOperations` object when the key is opaque.
571
- * Otherwise returns a stable lazy wrap over {@link getPrivateKey}: its
572
- * methods resolve the key on first use (disk read, passphrase,
573
- * `privateKeyProvider` — all async), so the wrap offers no synchronous
574
- * fast path; callers that need one resolve the key themselves and build
575
- * a `LocalKeyOperations` over it. The wrap follows key rotation: a
576
- * `privateKeyProvider` that starts returning a different key gets a
577
- * fresh underlying `LocalKeyOperations`.
578
- */
579
- getKeyOperations(): IKeyOperations;
580
- /**
581
- * Enable, disable, or rotate the passphrase protecting the on-disk
582
- * private key: decrypt with `oldPassphrase` (omit if the key is
583
- * currently unencrypted), then write back encrypted with
584
- * `newPassphrase` (omit to leave it unencrypted). The write goes to a
585
- * temporary file in the same directory and is atomically renamed into
586
- * place, so a crash mid-rotation cannot leave a partially-written key;
587
- * the temporary file is removed if anything fails, so a rotation *to*
588
- * plaintext can never leave a stray cleartext copy behind. Runs under
589
- * the same lock as `initialize()`.
590
- *
591
- * This only rewrites the on-disk file — it does not update this
592
- * instance's own `privateKeyPassphrase` (set at construction), and it
593
- * drops this instance's cached key so that disk stays the source of
594
- * truth. Construct a new `CertificateManager` with the new passphrase to
595
- * continue using it afterward.
596
- *
597
- * Not supported when a `privateKeyProvider` is configured (there is no
598
- * disk file for this method to rewrite).
599
- */
600
- reencryptPrivateKey(oldPassphrase?: PrivateKeyPassphrase, newPassphrase?: PrivateKeyPassphrase): Promise<void>;
601
- /** Path to the OpenSSL random seed file. */
602
- get randomFile(): string;
603
- /**
604
- * Move a certificate to the rejected store.
605
- * If the certificate was previously trusted, it will be removed from the trusted folder.
606
- * @param certificateOrChain - the DER-encoded certificate or certificate chain
607
- */
608
- rejectCertificate(certificateOrChain: Certificate | Certificate[]): Promise<void>;
609
- /**
610
- * Move a certificate to the trusted store.
611
- * If the certificate was previously rejected, it will be removed from the rejected folder.
612
- * @param certificateOrChain - the DER-encoded certificate or certificate chain
613
- */
614
- trustCertificate(certificateOrChain: Certificate | Certificate[]): Promise<void>;
615
- /**
616
- * Check whether the trusted certificate store is empty.
617
- *
618
- * This inspects the in-memory index, which is kept in
619
- * sync with the `trusted/certs/` folder by file-system
620
- * watchers after {@link initialize} has been called.
621
- */
622
- isTrustListEmpty(): boolean;
623
- /**
624
- * Return the number of certificates currently in the
625
- * trusted store.
626
- */
627
- getTrustedCertificateCount(): number;
628
- /** Path to the rejected certificates folder. */
629
- get rejectedFolder(): string;
630
- /** Path to the trusted certificates folder. */
631
- get trustedFolder(): string;
632
- /** Path to the trusted CRL folder. */
633
- get crlFolder(): string;
634
- /** Path to the issuer (CA) certificates folder. */
635
- get issuersCertFolder(): string;
636
- /** Path to the issuer CRL folder. */
637
- get issuersCrlFolder(): string;
638
- /** Path to the own certificate folder. */
639
- get ownCertFolder(): string;
640
- get ownPrivateFolder(): string;
641
- /**
642
- * Check if a certificate is in the trusted store.
643
- * If the certificate is unknown and `untrustUnknownCertificate` is set,
644
- * it will be written to the rejected folder.
645
- * @param certificate - the DER-encoded certificate
646
- * @returns `"Good"` if trusted, `"BadCertificateUntrusted"` if rejected/unknown,
647
- * or `"BadCertificateInvalid"` if the certificate cannot be parsed.
648
- */
649
- isCertificateTrusted(certificateOrCertificateChain: Certificate | Certificate[]): Promise<"Good" | "BadCertificateUntrusted" | "BadCertificateInvalid">;
650
- /**
651
- * Internal verification hook called by {@link verifyCertificate}.
652
- *
653
- * Subclasses can override this to inject additional validation
654
- * logic (e.g. application-level policy checks) while still
655
- * delegating to the default chain/CRL/trust verification.
656
- *
657
- * @param certificate - the DER-encoded certificate to verify
658
- * @param options - verification options forwarded from the
659
- * public API
660
- * @returns the verification status code
661
- */
662
- protected verifyCertificateAsync(certificate: Certificate | Certificate[], options: VerifyCertificateOptions): Promise<VerificationStatus>;
663
- /**
664
- * Verify a certificate against the PKI trust store.
665
- *
666
- * This performs a full validation including trust status,
667
- * issuer chain, CRL revocation checks, and time validity.
668
- *
669
- * @param certificate - the DER-encoded certificate to verify
670
- * @param options - optional flags to relax validation rules
671
- * @returns the verification status code
672
- */
673
- verifyCertificate(certificate: Certificate | Certificate[], options?: VerifyCertificateOptions): Promise<VerificationStatus>;
674
- /**
675
- * Initialize the PKI directory structure, generate the
676
- * private key (if missing), and start file-system watchers.
677
- *
678
- * This method is idempotent — subsequent calls are no-ops.
679
- * It must be called before any certificate operations.
680
- */
681
- initialize(): Promise<void>;
682
- /**
683
- * Dispose of the CertificateManager, releasing file watchers
684
- * and other resources. The instance should not be used after
685
- * calling this method.
686
- */
687
- dispose(): Promise<void>;
688
- /**
689
- * Force a full re-scan of all PKI folders, rebuilding
690
- * the in-memory `_thumbs` index from scratch.
691
- *
692
- * Call this after external processes have modified the
693
- * PKI folders (e.g. via `writeTrustList` or CLI tools)
694
- * to ensure the CertificateManager sees the latest
695
- * state without waiting for file-system events.
696
- */
697
- reloadCertificates(): Promise<void>;
698
- protected withLock2<T>(action: () => Promise<T>): Promise<T>;
699
- /**
700
- * Create a self-signed certificate for this PKI's private key.
701
- *
702
- * The certificate is written to `params.outputFile` or
703
- * `own/certs/self_signed_certificate.pem` by default.
704
- *
705
- * @param params - certificate parameters (subject, SANs,
706
- * validity, etc.)
707
- */
708
- createSelfSignedCertificate(params: CreateSelfSignCertificateParam1): Promise<void>;
709
- /**
710
- * Create a Certificate Signing Request (CSR) using this
711
- * PKI's private key and configuration.
712
- *
713
- * The CSR file is written to `own/certs/` with a timestamped
714
- * filename.
715
- *
716
- * @param params - CSR parameters (subject, SANs)
717
- * @returns the filesystem path to the generated CSR file
718
- */
719
- createCertificateRequest(params: CreateSelfSignCertificateParam): Promise<Filename>;
720
- /**
721
- * Add a CA (issuer) certificate to the issuers store.
722
- * If the certificate is already present, this is a no-op.
723
- * @param certificate - the DER-encoded CA certificate
724
- * @param validate - if `true`, verify the certificate before adding
725
- * @param addInTrustList - if `true`, also add to the trusted store
726
- * @returns `VerificationStatus.Good` on success
727
- */
728
- addIssuer(certificate: DER, validate?: boolean, addInTrustList?: boolean): Promise<VerificationStatus>;
729
- /**
730
- * Add multiple CA (issuer) certificates to the issuers store.
731
- * @param certificates - the DER-encoded CA certificates
732
- * @param validate - if `true`, verify each certificate before adding
733
- * @param addInTrustList - if `true`, also add each certificate to the trusted store
734
- * @returns `VerificationStatus.Good` on success
735
- */
736
- addIssuers(certificates: Certificate[], validate?: boolean, addInTrustList?: boolean): Promise<VerificationStatus>;
737
- /**
738
- * Add a CRL to the certificate manager.
739
- * @param crl - the CRL to add
740
- * @param target - "issuers" (default) writes to issuers/crl, "trusted" writes to trusted/crl
741
- */
742
- addRevocationList(crl: CertificateRevocationList, target?: "issuers" | "trusted"): Promise<VerificationStatus>;
743
- /**
744
- * Remove all CRL files from the specified folder(s) and clear the
745
- * corresponding in-memory index.
746
- * @param target - "issuers" clears issuers/crl, "trusted" clears
747
- * trusted/crl, "all" clears both.
748
- */
749
- clearRevocationLists(target: "issuers" | "trusted" | "all"): Promise<void>;
750
- /**
751
- * Check whether an issuer certificate with the given thumbprint
752
- * is already registered.
753
- * @param thumbprint - hex-encoded SHA-1 thumbprint (lowercase)
754
- */
755
- hasIssuer(thumbprint: string): Promise<boolean>;
756
- /**
757
- * Remove a trusted certificate identified by its SHA-1 thumbprint.
758
- * Deletes the file on disk and removes the entry from the
759
- * in-memory index.
760
- * @param thumbprint - hex-encoded SHA-1 thumbprint (lowercase)
761
- * @returns the removed certificate buffer, or `null` if not found
762
- */
763
- removeTrustedCertificate(thumbprint: string): Promise<Certificate | null>;
764
- /**
765
- * Remove an issuer certificate identified by its SHA-1 thumbprint.
766
- * Deletes the file on disk and removes the entry from the
767
- * in-memory index.
768
- * @param thumbprint - hex-encoded SHA-1 thumbprint (lowercase)
769
- * @returns the removed certificate buffer, or `null` if not found
770
- */
771
- removeIssuer(thumbprint: string): Promise<Certificate | null>;
772
- /**
773
- * Remove all CRL files that were issued by the given CA certificate
774
- * from the specified folder (or both).
775
- * @param issuerCertificate - the CA certificate whose CRLs to remove
776
- * @param target - "issuers", "trusted", or "all" (default "all")
777
- */
778
- removeRevocationListsForIssuer(issuerCertificate: Certificate, target?: "issuers" | "trusted" | "all"): Promise<void>;
779
- /**
780
- * Validate a certificate (optionally with its chain) and add
781
- * the leaf certificate to the trusted store.
782
- *
783
- * Performs OPC UA Part 4, Table 100 validation:
784
- *
785
- * 1. **Certificate Structure** — parse the DER encoding.
786
- * 2. **Build Certificate Chain** — walk from the leaf to a
787
- * self-signed root CA, using the provided chain and the
788
- * issuers store.
789
- * 3. **Signature** — verify each certificate's signature
790
- * against its issuer.
791
- * 4. **Issuer Presence** — every issuer in the chain must
792
- * already be registered in the issuers store (per GDS
793
- * 7.8.2.6).
794
- * 5. **Validity Period** — each certificate must be within
795
- * its validity window (overridable via
796
- * {@link AddCertificateValidationOptions.acceptExpiredCertificate}).
797
- * 6. **Revocation Check** — each certificate is checked
798
- * against its issuer's CRL (overridable via
799
- * {@link AddCertificateValidationOptions.acceptRevokedCertificate}
800
- * and {@link AddCertificateValidationOptions.ignoreMissingRevocationList}).
801
- *
802
- * Only the leaf certificate is added to the trusted store.
803
- *
804
- * @param certificateChain - DER-encoded certificate or chain
805
- * @returns `VerificationStatus.Good` on success, or an error
806
- * status indicating why the certificate was rejected.
807
- */
808
- addTrustedCertificateFromChain(certificateChain: Certificate | Certificate[]): Promise<VerificationStatus>;
809
- /**
810
- * Check whether an issuer certificate is still needed by any
811
- * certificate in the trusted store.
812
- *
813
- * This is used before removing an issuer to ensure that
814
- * doing so would not break the chain of any trusted
815
- * certificate.
816
- *
817
- * @param issuerCertificate - the CA certificate to check
818
- * @returns `true` if at least one trusted certificate was
819
- * signed by this issuer.
820
- */
821
- isIssuerInUseByTrustedCertificate(issuerCertificate: Certificate): Promise<boolean>;
822
- /**
823
- * find the issuer certificate among the trusted issuer certificates.
824
- *
825
- * The findIssuerCertificate method is an asynchronous method that attempts to find
826
- * the issuer certificate for a given certificate from the list of issuer certificate declared in the PKI
827
- *
828
- * - If the certificate is self-signed, it returns the certificate itself.
829
- *
830
- * - If the certificate has no extension 3, it is assumed to be generated by an old system, and a null value is returned.
831
- *
832
- * - the method checks both issuer and trusted certificates and returns the appropriate issuercertificate,
833
- * if found. If multiple matching certificates are found, a warning is logged to the console.
834
- *
835
- */
836
- findIssuerCertificate(certificate: Certificate | Certificate[]): Promise<Certificate | null>;
837
- /**
838
- * Outcome status for {@link CertificateManager.completeCertificateChain}.
839
- */
840
- static readonly ChainCompletionStatus: typeof ChainCompletionStatus;
841
- /**
842
- * Complete a certificate chain by walking the issuer store.
843
- *
844
- * Starting from the last certificate in the provided chain, this method
845
- * repeatedly calls {@link findIssuerCertificate} to locate the parent
846
- * certificate until it reaches a self-signed root or can no longer find
847
- * an issuer.
848
- *
849
- * @param chain - the (potentially partial) certificate chain, leaf first
850
- * @param maxDepth - maximum number of issuers to append (default: 10)
851
- * @returns a {@link ChainCompletionResult} containing the (possibly completed)
852
- * chain, a status code, and an optional diagnostic message.
853
- */
854
- completeCertificateChain(chain: Certificate[], maxDepth?: number): Promise<ChainCompletionResult>;
855
- /**
856
- * Check whether a certificate has been revoked by its issuer's CRL.
857
- *
858
- * - Self-signed certificates are never considered revoked.
859
- * - If no `issuerCertificate` is provided, the method attempts
860
- * to find it via {@link findIssuerCertificate}.
861
- *
862
- * @param certificate - the DER-encoded certificate to check
863
- * @param issuerCertificate - optional issuer certificate; looked
864
- * up automatically when omitted
865
- * @returns `Good` if not revoked, `BadCertificateRevoked` if the
866
- * serial number appears in a CRL,
867
- * `BadCertificateRevocationUnknown` if no CRL is available,
868
- * or `BadCertificateChainIncomplete` if the issuer cannot be
869
- * found.
870
- */
871
- isCertificateRevoked(certificate: Certificate | Certificate[], issuerCertificate?: Certificate | null): Promise<VerificationStatus>;
872
- }
873
-
874
- /**
875
- * Options for creating a PFX (PKCS#12) file.
876
- */
877
- interface CreatePFXOptions {
878
- /** Path to the certificate file (PEM or DER). */
879
- certificateFile: Filename;
880
- /** Path to the private key file (PEM, plaintext or encrypted PKCS#8). */
881
- privateKeyFile: Filename;
882
- /**
883
- * Passphrase that decrypts `privateKeyFile` if it is an encrypted
884
- * PKCS#8 key (e.g. a `CertificateManager` created with
885
- * `privateKeyPassphrase`). Omit for a plaintext key. This is distinct
886
- * from `passphrase`, which protects the *output* PFX bundle.
887
- */
888
- privateKeyPassphrase?: string;
889
- /** Output path for the generated PFX file. */
890
- outputFile: Filename;
891
- /**
892
- * Optional passphrase to protect the PFX file.
893
- * If omitted, the PFX is created without a password.
894
- */
895
- passphrase?: string;
896
- /**
897
- * Optional path(s) to CA / intermediate certificate files
898
- * to include in the PFX bundle.
899
- */
900
- caCertificateFiles?: Filename[];
901
- /**
902
- * Optional display label stored on the bundle, the equivalent of
903
- * openssl's `-name`. The Windows certificate store and `keytool` show
904
- * it; {@link extractAllFromPFX} and {@link dumpPFX} report it back.
905
- */
906
- friendlyName?: string;
907
- }
908
- /**
909
- * Options for extracting data from a PFX (PKCS#12) file.
910
- */
911
- interface ExtractPFXOptions {
912
- /** Path to the PFX file. */
913
- pfxFile: Filename;
914
- /**
915
- * Passphrase used when the PFX was created.
916
- * Pass an empty string for unprotected PFX files.
917
- */
918
- passphrase?: string;
919
- }
920
- /**
921
- * Result of extracting data from a PFX file.
922
- */
923
- interface ExtractPFXResult {
924
- /** The certificate in PEM format. */
925
- certificate: string;
926
- /** The private key in PEM format. */
927
- privateKey: string;
928
- /**
929
- * The CA / intermediate certificates in PEM format
930
- * (empty string if none).
931
- */
932
- caCertificates: string;
933
- /** The display label the bundle carries, if it has one. */
934
- friendlyName?: string;
935
- }
936
- /**
937
- * Create a PFX (PKCS#12) file from a certificate and private key.
938
- *
939
- * The bundle is protected with PBES2 / AES-256-CBC under an SHA-256 MAC. If
940
- * `certificateFile` holds more than one PEM block, the first is the
941
- * identity and the rest join the issuer chain, ahead of any
942
- * `caCertificateFiles`.
943
- *
944
- * Nothing is written unless every input reads back cleanly and the private
945
- * key belongs to the certificate, so a wrong `privateKeyPassphrase` or a
946
- * mismatched pair leaves no half-made file behind.
947
- *
948
- * @param options - see {@link CreatePFXOptions}
949
- */
950
- declare function createPFX(options: CreatePFXOptions): Promise<void>;
951
- /**
952
- * Extract the client/server certificate from a PFX file.
953
- *
954
- * @returns the certificate in PEM format.
955
- */
956
- declare function extractCertificateFromPFX(options: ExtractPFXOptions): Promise<string>;
957
- /**
958
- * Extract the private key from a PFX file.
959
- *
960
- * @returns the private key as unencrypted PKCS#8 PEM.
961
- */
962
- declare function extractPrivateKeyFromPFX(options: ExtractPFXOptions): Promise<string>;
963
- /**
964
- * Extract the CA / intermediate certificates from a PFX file.
965
- *
966
- * @returns the CA certificates in PEM format
967
- * (empty string if none are present).
968
- */
969
- declare function extractCACertificatesFromPFX(options: ExtractPFXOptions): Promise<string>;
970
- /**
971
- * Extract certificate + private key + CA certs from a PFX file
972
- * in a single call.
973
- *
974
- * Prefer this over the single-part helpers when you want more than one
975
- * part: the file is read, decrypted and MAC-verified once here, against
976
- * once per part.
977
- *
978
- * @returns an {@link ExtractPFXResult} with all PEM-encoded parts.
979
- */
980
- declare function extractAllFromPFX(options: ExtractPFXOptions): Promise<ExtractPFXResult>;
981
- /**
982
- * Convert a PFX file to a single PEM file holding the private key, the
983
- * certificate, and any issuer certificates the bundle carries, in that
984
- * order.
985
- */
986
- declare function convertPFXtoPEM(pfxFile: Filename, pemFile: Filename, passphrase?: string): Promise<void>;
987
- /**
988
- * Dump the contents of a PFX file in human-readable form.
989
- *
990
- * The layout is this package's own, not `openssl pkcs12 -info`'s: it
991
- * describes the identity the bundle carries rather than the algorithms it
992
- * was encrypted with, and it states outright whether the enclosed key
993
- * matches the enclosed certificate - the question a bundle that will not
994
- * load is usually being asked. Treat the text as something to read, not to
995
- * parse; use {@link extractAllFromPFX} to get at the parts.
996
- *
997
- * @returns the human-readable dump as a string.
998
- */
999
- declare function dumpPFX(pfxFile: Filename, passphrase?: string): Promise<string>;
1000
-
1001
- export { type AddCertificateValidationOptions, CaBackend, CertificateAuthority, CertificateAuthorityCore, CertificateAuthorityCoreOptions, type CertificateAuthorityOptions, CertificateManager, type CertificateManagerEvents, type CertificateManagerOptions, CertificateManagerState, type CertificateStore, type ChainCompletionResult, ChainCompletionStatus, type CreatePFXOptions, CreateSelfSignCertificateParam, type CreateSelfSignCertificateParam1, type CrlStore, type ExtractPFXOptions, type ExtractPFXResult, Filename, KeySize, OpenSslCaBackend, Params, PrivateKeyPassphrase, PrivateKeyProvider, ProcessAltNamesParam, VerificationStatus, type VerifyCertificateOptions, coerceCertificateChain, convertPFXtoPEM, createPFX, dumpPFX, extractAllFromPFX, extractCACertificatesFromPFX, extractCertificateFromPFX, extractPrivateKeyFromPFX, findIssuerCertificateInChain, install_prerequisite, isIntermediateIssuer, isIssuer, isRootIssuer, makeFingerprint };