Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

improvement(pki): read PKCS#12 keystores in the browser

Saif68f247614c29
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts
index 6820a29456..5b5d31b571 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -393,7 +393,6 @@ export enum EventType {
GET_CERT_PRIVATE_KEY = "get-cert-private-key",
GET_CERT_BUNDLE = "get-cert-bundle",
EXPORT_CERT_PKCS12 = "export-cert-pkcs12",
- EXTRACT_CERT_PKCS12 = "extract-cert-pkcs12",
CREATE_PKI_ALERT = "create-pki-alert",
GET_PKI_ALERT = "get-pki-alert",
UPDATE_PKI_ALERT = "update-pki-alert",
@@ -3124,15 +3123,6 @@ interface GetCertPkcs12 {
};
}
-interface ExtractCertPkcs12 {
- type: EventType.EXTRACT_CERT_PKCS12;
- metadata: {
- entryCount: number;
- subjects: string[];
- applicationId?: string;
- };
-}
-
interface CreatePkiAlert {
type: EventType.CREATE_PKI_ALERT;
metadata: {
@@ -7216,7 +7206,6 @@ export type Event =
| GetCertPrivateKey
| GetCertBundle
| GetCertPkcs12
- | ExtractCertPkcs12
| CreatePkiAlert
| GetPkiAlert
| UpdatePkiAlert
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index 3ac9349415..33907cde81 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -2121,27 +2121,6 @@ export const CERTIFICATES = {
privateKey:
"The PEM-encoded private key associated with the imported certificate. Returned only when a private key was supplied at import.",
serialNumber: "The serial number of the imported certificate."
- },
- EXTRACT_PKCS12: {
- pkcs12: "The base64-encoded PKCS#12 keystore (.p12 or .pfx) to read.",
- password: "The password protecting the keystore. Pass an empty string for a keystore without one.",
- applicationId: "The ID of the Application the certificates will be imported into.",
-
- entries: "The certificate and private key pairs found in the keystore.",
- alias: "The friendly name the keystore records for this entry, if it has one.",
- subject: "The distinguished name of the certificate.",
- commonName: "The common name of the certificate, if it has one.",
- altNames: "The subject alternative names of the certificate, comma separated, if it has any.",
- keyAlgorithm: "The algorithm and size of the private key, such as 'RSA 2048' or 'ECDSA P-256'.",
- notAfter: "The date the certificate expires.",
- fingerprintSha256: "The SHA-256 fingerprint of the certificate.",
- chainWarning:
- "Set when no usable issuer chain was found in the keystore, in which case the certificate is returned on its own.",
- entryCertificatePem: "The PEM-encoded certificate, ready to pass to the import endpoint.",
- entryChainPem:
- "The PEM-encoded issuer chain, ordered from the closest issuer outwards. Absent when none was found.",
- entryPrivateKeyPem:
- "The PEM-encoded private key belonging to this certificate. Absent for a keystore that holds certificates only."
}
};
diff --git a/backend/src/lib/logger/logger.ts b/backend/src/lib/logger/logger.ts
index 3ab0484363..bbe71966dc 100644
--- a/backend/src/lib/logger/logger.ts
+++ b/backend/src/lib/logger/logger.ts
@@ -55,7 +55,6 @@ const redactedKeys = [
"token",
"privateKey",
"privateKeyPem",
- "pkcs12",
"serverPrivateKey",
"plainPrivateKey",
"plainProjectKey",
diff --git a/backend/src/server/config/rateLimiter.ts b/backend/src/server/config/rateLimiter.ts
index 8e1360a22d..536238fb2d 100644
--- a/backend/src/server/config/rateLimiter.ts
+++ b/backend/src/server/config/rateLimiter.ts
@@ -99,14 +99,6 @@ export const invalidateCacheLimit: RateLimitOptions = {
keyGenerator: (req) => req.realIp
};
-// Opening a keystore is CPU work whose cost the uploaded file chooses
-export const pkcs12ExtractionLimit: RateLimitOptions = {
- timeWindow: 60 * 1000,
- hook: "preValidation",
- max: 20,
- keyGenerator: (req) => req.realIp
-};
-
// Makes spamming "request access" harder, preventing email DDoS
export const requestAccessLimit: RateLimitOptions = {
timeWindow: 60 * 1000,
diff --git a/backend/src/server/routes/v1/certificate-router.ts b/backend/src/server/routes/v1/certificate-router.ts
index 5b8bb1cac2..7611415e2c 100644
--- a/backend/src/server/routes/v1/certificate-router.ts
+++ b/backend/src/server/routes/v1/certificate-router.ts
@@ -5,11 +5,10 @@ import { z } from "zod";
import { CertificatesSchema } from "@app/db/schemas";
import { EventType } from "@app/ee/services/audit-log/audit-log-types";
import { ApiDocsTags, CERTIFICATES } from "@app/lib/api-docs";
-import { getBase64SizeInBytes, isBase64 } from "@app/lib/base64";
import { NotFoundError } from "@app/lib/errors";
import { ms } from "@app/lib/ms";
import { isUuidV4 } from "@app/lib/validator";
-import { pkcs12ExtractionLimit, readLimit, writeLimit } from "@app/server/config/rateLimiter";
+import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { addNoCacheHeaders } from "@app/server/lib/caching";
import { openApiHidden } from "@app/server/lib/schemas";
import { getTelemetryDistinctId } from "@app/server/lib/telemetry";
@@ -122,21 +121,6 @@ const validateDateOrder = (data: {
return true;
};
-const MAX_PKCS12_BYTES = 1024 * 1024;
-// A 1MB keystore is ~1.37MB base64, plus the JSON envelope.
-const MAX_PKCS12_BODY_LIMIT_BYTES = 2 * 1024 * 1024;
-
-const createBase64Schema = (field: string, maxBytes: number) =>
- z.string().superRefine((val, ctx) => {
- if (!isBase64(val)) {
- ctx.addIssue({ code: z.ZodIssueCode.custom, message: `${field} must be base64 encoded` });
- }
-
- if (getBase64SizeInBytes(val) > maxBytes) {
- ctx.addIssue({ code: z.ZodIssueCode.custom, message: `${field} cannot exceed ${maxBytes} bytes` });
- }
- });
-
export const registerCertificateRouter = async (server: FastifyZodProvider) => {
server.route({
method: "POST",
@@ -1591,77 +1575,6 @@ export const registerCertificateRouter = async (server: FastifyZodProvider) => {
}
});
- // An action rather than a resource, so a deliberate REST deviation, as with /import-certificate.
- server.route({
- method: "POST",
- bodyLimit: MAX_PKCS12_BODY_LIMIT_BYTES,
- url: "/pkcs12/extract",
- config: {
- rateLimit: pkcs12ExtractionLimit
- },
- onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
- schema: {
- hide: false,
- operationId: "extractPkcs12",
- tags: [ApiDocsTags.PkiCertificates],
- description: "Read the certificates and private keys held in a PKCS#12 keystore",
- body: z.object({
- pkcs12: createBase64Schema("pkcs12", MAX_PKCS12_BYTES).describe(CERTIFICATES.EXTRACT_PKCS12.pkcs12),
- password: z.string().max(1024).describe(CERTIFICATES.EXTRACT_PKCS12.password),
- applicationId: z.string().trim().uuid().optional().describe(CERTIFICATES.EXTRACT_PKCS12.applicationId)
- }),
- response: {
- 200: z.object({
- entries: z
- .array(
- z.object({
- alias: z.string().max(1024).nullable().describe(CERTIFICATES.EXTRACT_PKCS12.alias),
- subject: z.string().max(2048).describe(CERTIFICATES.EXTRACT_PKCS12.subject),
- commonName: z.string().max(1024).nullable().describe(CERTIFICATES.EXTRACT_PKCS12.commonName),
- altNames: z.string().max(2048).nullable().describe(CERTIFICATES.EXTRACT_PKCS12.altNames),
- keyAlgorithm: z.string().max(64).describe(CERTIFICATES.EXTRACT_PKCS12.keyAlgorithm),
- notAfter: z.string().describe(CERTIFICATES.EXTRACT_PKCS12.notAfter),
- fingerprintSha256: z.string().max(256).describe(CERTIFICATES.EXTRACT_PKCS12.fingerprintSha256),
- chainWarning: z.string().max(512).nullable().describe(CERTIFICATES.EXTRACT_PKCS12.chainWarning),
- certificatePem: z.string().describe(CERTIFICATES.EXTRACT_PKCS12.entryCertificatePem),
- chainPem: z.string().optional().describe(CERTIFICATES.EXTRACT_PKCS12.entryChainPem),
- privateKeyPem: z.string().optional().describe(CERTIFICATES.EXTRACT_PKCS12.entryPrivateKeyPem)
- })
- )
- .describe(CERTIFICATES.EXTRACT_PKCS12.entries)
- })
- }
- },
- handler: async (req, reply) => {
- const { entries } = await server.services.certificate.extractPkcs12({
- actor: req.permission.type,
- actorId: req.permission.id,
- actorAuthMethod: req.permission.authMethod,
- actorOrgId: req.permission.orgId,
- projectId: req.internalCertManagerProjectId,
- ...req.body
- });
-
- await server.services.auditLog.createAuditLog({
- ...req.auditLogInfo,
- projectId: req.internalCertManagerProjectId,
- event: {
- type: EventType.EXTRACT_CERT_PKCS12,
- metadata: {
- entryCount: entries.length,
- subjects: entries.slice(0, 25).map((entry) => entry.subject.slice(0, 256)),
- applicationId: req.body.applicationId
- }
- }
- });
-
- // The response carries private keys.
- addNoCacheHeaders(reply);
-
- return { entries };
- }
- });
-
server.route({
method: "POST",
url: "/import-certificate",
diff --git a/backend/src/services/certificate/certificate-pkcs12-runner.ts b/backend/src/services/certificate/certificate-pkcs12-runner.ts
deleted file mode 100644
index 4e99fb76df..0000000000
--- a/backend/src/services/certificate/certificate-pkcs12-runner.ts
+++ /dev/null
@@ -1,127 +0,0 @@
-import path from "node:path";
-import { Worker } from "node:worker_threads";
-
-import { BadRequestError } from "@app/lib/errors";
-import { logger } from "@app/lib/logger";
-
-import { Pkcs12ErrorCode, TExtractPkcs12Result, TPkcs12ErrorCode } from "./certificate-pkcs12-fns";
-
-// Cost is refused up front by the extraction itself, so this is only a backstop for anything that
-// check cannot see, and node-forge decrypts synchronously so it has to run off the event loop.
-const EXTRACTION_TIMEOUT_MS = 5_000;
-const MAX_CONCURRENT_EXTRACTIONS = 2;
-
-let inFlight = 0;
-
-const acquireSlot = () => {
- if (inFlight >= MAX_CONCURRENT_EXTRACTIONS) {
- throw new BadRequestError({
- message: "Too many keystores are being read right now. Try again in a moment."
- });
- }
- inFlight += 1;
-};
-
-const releaseSlot = () => {
- inFlight -= 1;
-};
-
-// Dev runs the TypeScript sources, production the ESM build; anchor on this module's own extension.
-const isRunningFromSource = __filename.endsWith(".ts");
-const moduleExtension = isRunningFromSource ? ".ts" : ".mjs";
-const workerPath = path.join(__dirname, `certificate-pkcs12-worker${moduleExtension}`);
-const extractionModulePath = path.join(__dirname, `certificate-pkcs12-fns${moduleExtension}`);
-
-// Node sniffs the module type of a .ts file and warns on every spawn, burying the dev log.
-const workerExecArgv = isRunningFromSource ? ["--no-warnings"] : undefined;
-
-type TWorkerResponse =
- | { ok: true; result: TExtractPkcs12Result }
- | { ok: false; code?: TPkcs12ErrorCode; count?: number; unexpected?: string };
-
-const errorMessage = (code: TPkcs12ErrorCode, count?: number) => {
- switch (code) {
- case Pkcs12ErrorCode.NotAKeystore:
- return "This file is not a valid PKCS#12 keystore. Upload a .p12 or .pfx file.";
- case Pkcs12ErrorCode.UnsupportedEntries:
- return "This keystore contains entry types we cannot read, such as secret keys. Export only the certificate and its private key, then try again.";
- case Pkcs12ErrorCode.TooManyBags:
- return `This keystore contains ${count ?? "too many"} entries, which is more than we can import at once.`;
- case Pkcs12ErrorCode.NoEntries:
- return "This keystore contains no certificates or private keys.";
- case Pkcs12ErrorCode.TooExpensive:
- return "This keystore asks for an unusually high number of key-derivation rounds, so we will not open it.";
- case Pkcs12ErrorCode.NoPairs:
- return `This keystore contains ${count ?? "some"} private key${count === 1 ? "" : "s"}, but none of them match a certificate in the file.`;
- case Pkcs12ErrorCode.BadPassword:
- default:
- return "Could not open the keystore. Check the password and try again.";
- }
-};
-
-export const runPkcs12Extraction = async ({
- pkcs12,
- password
-}: {
- pkcs12: Buffer;
- password: string;
-}): Promise<TExtractPkcs12Result> => {
- acquireSlot();
-
- try {
- return await new Promise<TExtractPkcs12Result>((resolve, reject) => {
- const worker = new Worker(workerPath, {
- workerData: { pkcs12: pkcs12.toString("base64"), password, modulePath: extractionModulePath },
- ...(workerExecArgv ? { execArgv: workerExecArgv } : {})
- });
-
- let settled = false;
- let timer: NodeJS.Timeout;
- const finish = (fn: () => void) => {
- if (settled) return;
- settled = true;
- clearTimeout(timer);
- void worker.terminate();
- fn();
- };
-
- timer = setTimeout(
- () => finish(() => reject(new BadRequestError({ message: "Could not read this keystore." }))),
- EXTRACTION_TIMEOUT_MS
- );
-
- worker.on("message", (message: TWorkerResponse) => {
- finish(() => {
- if (message.ok) {
- resolve(message.result);
- return;
- }
- if (message.unexpected) {
- logger.error(`PKCS#12 extraction failed unexpectedly [reason=${message.unexpected}]`);
- reject(new BadRequestError({ message: "Could not read this keystore." }));
- return;
- }
- reject(
- new BadRequestError({ message: errorMessage(message.code ?? Pkcs12ErrorCode.BadPassword, message.count) })
- );
- });
- });
-
- worker.on("error", (err) => {
- finish(() => {
- logger.error(err, "PKCS#12 extraction worker failed");
- reject(new BadRequestError({ message: "Could not read this keystore." }));
- });
- });
-
- worker.on("exit", (code) => {
- finish(() => {
- logger.error(`PKCS#12 extraction worker exited early [exitCode=${code}]`);
- reject(new BadRequestError({ message: "Could not read this keystore." }));
- });
- });
- });
- } finally {
- releaseSlot();
- }
-};
diff --git a/backend/src/services/certificate/certificate-pkcs12-worker.ts b/backend/src/services/certificate/certificate-pkcs12-worker.ts
deleted file mode 100644
index 4bbaa45b1e..0000000000
--- a/backend/src/services/certificate/certificate-pkcs12-worker.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import { parentPort, workerData } from "node:worker_threads";
-
-import type { TExtractPkcs12Result } from "./certificate-pkcs12-fns";
-
-// In development Node loads this file directly and strips its types without a compiler, so keep it
-// free of non-erasable TypeScript.
-
-type TWorkerInput = { pkcs12: string; password: string; modulePath: string };
-
-const { pkcs12, password, modulePath } = workerData as TWorkerInput;
-
-type TExtractionModule = {
- extractPkcs12Entries: (input: { pkcs12: Buffer; password: string }) => Promise<TExtractPkcs12Result>;
- Pkcs12ExtractionError: new (code: string, count?: number) => Error & { code: string; count?: number };
-};
-
-const run = async () => {
- const mod = (await import(modulePath)) as TExtractionModule;
-
- try {
- const result = await mod.extractPkcs12Entries({ pkcs12: Buffer.from(pkcs12, "base64"), password });
- parentPort?.postMessage({ ok: true, result });
- } catch (err) {
- if (err instanceof mod.Pkcs12ExtractionError) {
- parentPort?.postMessage({ ok: false, code: err.code, count: err.count });
- return;
- }
- parentPort?.postMessage({ ok: false, unexpected: err instanceof Error ? err.message : "unknown error" });
- }
-};
-
-void run();
diff --git a/backend/src/services/certificate/certificate-service.ts b/backend/src/services/certificate/certificate-service.ts
index ae1f577e5e..035e050fce 100644
--- a/backend/src/services/certificate/certificate-service.ts
+++ b/backend/src/services/certificate/certificate-service.ts
@@ -54,7 +54,6 @@ import {
revocationReasonToCrlCode,
splitPemChain
} from "./certificate-fns";
-import { runPkcs12Extraction } from "./certificate-pkcs12-runner";
import { TCertificateSecretDALFactory } from "./certificate-secret-dal";
import {
CertExtendedKeyUsage,
@@ -66,7 +65,6 @@ import {
TCertificateFingerprints,
TCertificateSubject,
TDeleteCertDTO,
- TExtractPkcs12DTO,
TGetCertBodyDTO,
TGetCertBundleDTO,
TGetCertDTO,
@@ -709,55 +707,6 @@ export const certificateServiceFactory = ({
};
};
- const extractPkcs12 = async ({
- projectId,
- applicationId,
- pkcs12,
- password,
- actorId,
- actorAuthMethod,
- actor,
- actorOrgId
- }: TExtractPkcs12DTO) => {
- if (applicationId) {
- const application = await pkiApplicationDAL.findById(applicationId);
- if (!application || application.projectId !== projectId) {
- throw new NotFoundError({ message: `Application with id '${applicationId}' not found.` });
- }
-
- const { permission } = await permissionService.getResourcePermission({
- actor,
- actorId,
- projectId,
- resourceType: ResourceType.CertificateApplication,
- resourceId: applicationId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ResourcePermissionCertificateActions.Import,
- ResourcePermissionSub.Certificates
- );
- } else {
- const { permission } = await permissionService.getProjectPermission({
- actor,
- actorId,
- projectId,
- actorAuthMethod,
- actorOrgId,
- actionProjectType: ActionProjectType.CertificateManager
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionCertificateActions.Import,
- ProjectPermissionSub.Certificates
- );
- }
-
- return runPkcs12Extraction({ pkcs12: Buffer.from(pkcs12, "base64"), password });
- };
-
/**
* Import certificate
*/
@@ -1004,7 +953,7 @@ export const certificateServiceFactory = ({
// @ts-expect-error We're expecting a database error
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (error?.error?.code === "23505") {
- throw new BadRequestError({ message: "Certificate serial already exists in your project" });
+ throw new BadRequestError({ message: "A certificate with this serial number has already been imported" });
}
throw error;
}
@@ -1293,7 +1242,6 @@ export const certificateServiceFactory = ({
revokeCert,
getCertBody,
importCert,
- extractPkcs12,
getCertBundle,
getCertPkcs12,
assignCertificateToApplication
diff --git a/backend/src/services/certificate/certificate-types.ts b/backend/src/services/certificate/certificate-types.ts
index e95ccd682b..5ea82d6761 100644
--- a/backend/src/services/certificate/certificate-types.ts
+++ b/backend/src/services/certificate/certificate-types.ts
@@ -152,14 +152,6 @@ export type TImportCertDTO = {
chainPem?: string;
} & Omit<TProjectPermission, "projectId">;
-export type TExtractPkcs12DTO = {
- projectId: string;
- applicationId?: string;
-
- pkcs12: string;
- password: string;
-} & Omit<TProjectPermission, "projectId">;
-
export type TGetCertPrivateKeyDTO = {
id?: string;
serialNumber?: string;
diff --git a/docs/api-reference/endpoints/certificates/extract-pkcs12.mdx b/docs/api-reference/endpoints/certificates/extract-pkcs12.mdx
deleted file mode 100644
index 10097987da..0000000000
--- a/docs/api-reference/endpoints/certificates/extract-pkcs12.mdx
+++ /dev/null
@@ -1,4 +0,0 @@
----
-title: "Extract PKCS#12"
-openapi: "POST /api/v1/cert-manager/certificates/pkcs12/extract"
----
diff --git a/docs/docs.json b/docs/docs.json
index c64964cb36..66608e3ac9 100644
--- a/docs/docs.json
+++ b/docs/docs.json
@@ -3677,8 +3677,7 @@
"api-reference/endpoints/certificates/cert-body",
"api-reference/endpoints/certificates/bundle",
"api-reference/endpoints/certificates/private-key",
- "api-reference/endpoints/certificates/import-certificate",
- "api-reference/endpoints/certificates/extract-pkcs12"
+ "api-reference/endpoints/certificates/import-certificate"
]
},
{
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index 618d899b09..0e6ce8561e 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -63,6 +63,7 @@
"@tanstack/virtual-file-routes": "^1.87.6",
"@tanstack/zod-adapter": "^1.91.0",
"@types/dagre": "^0.7.52",
+ "@types/node-forge": "^1.3.14",
"@types/nprogress": "^0.2.3",
"@ucast/mongo2js": "^1.3.4",
"@xterm/addon-fit": "^0.10.0",
@@ -84,6 +85,7 @@
"lexical": "^0.29.0",
"lucide-react": "^0.544.0",
"ms": "^2.1.3",
+ "node-forge": "^1.4.0",
"nprogress": "^0.2.0",
"picomatch": "^4.0.4",
"posthog-js": "^1.360.1",
@@ -161,8 +163,7 @@
"resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.4.4.tgz",
"integrity": "sha512-Elp+iwUx5rN5+Y8xLt5/GRoG20WGoDCQ/1Fb+1LiGtvwbDavuSk0jhD/eZdckHAuzcDzccnkv+rEjyWfRx18gg==",
"dev": true,
- "license": "MIT",
- "peer": true
+ "license": "MIT"
},
"node_modules/@alloc/quick-lru": {
"version": "5.2.0",
@@ -207,6 +208,7 @@
"integrity": "sha512-2BCOP7TN8M+gVDj7/ht3hsaO/B/n5oDbiAyyvnRlNOs+u1o+JWNYTQrmpuNp1/Wq2gcFrI01JAW+paEKDMx/CA==",
"dev": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"@babel/code-frame": "^7.27.1",
"@babel/generator": "^7.28.3",
@@ -499,6 +501,7 @@
"resolved": "https://registry.npmjs.org/@casl/ability/-/ability-6.8.0.tgz",
"integrity": "sha512-Ipt4mzI4gSgnomFdaPjaLgY2MWuXqAEZLrU6qqWBB7khGiBBuuEp6ytYDnq09bRXqcjaeeHiaCvCGFbBA2SpvA==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@ucast/mongo2js": "^1.3.0"
},
@@ -662,6 +665,7 @@
"resolved": "https://registry.npmjs.org/@dnd-kit/core/-/core-6.3.1.tgz",
"integrity": "sha512-xkGBRQQab4RLwgXxoqETICr6S5JlogafbhNsidmrkVv2YRs5MLwpjoF2qpiGjQt8S9AoxtIV603s0GIUpY5eYQ==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@dnd-kit/accessibility": "^3.1.1",
"@dnd-kit/utilities": "^3.2.2",
@@ -1521,6 +1525,7 @@
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-6.7.1.tgz",
"integrity": "sha512-8dBIHbfsKlCk2jHQ9PoRBg2Z+4TwyE3vZICSnoDlnsHA6SiMlTwfmW6yX0lHsRmWJugkeb92sA0hZdkXJhuz+g==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@fortawesome/fontawesome-common-types": "6.7.1"
},
@@ -2255,6 +2260,7 @@
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.0.tgz",
"integrity": "sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==",
"license": "Apache-2.0",
+ "peer": true,
"engines": {
"node": ">=8.0.0"
}
@@ -4915,6 +4921,7 @@
"integrity": "sha512-RnO1SaiCFHn666wNz2QfZEFxvmiNRqhzaMXHXxXXKt+MEP7aajlPxUSMIQpKAaJfverpovEYqjBOXDq6dDcaOQ==",
"dev": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"@typescript-eslint/utils": "^8.13.0",
"eslint-visitor-keys": "^4.2.0",
@@ -5510,6 +5517,7 @@
"resolved": "https://registry.npmjs.org/@tanstack/react-router/-/react-router-1.95.1.tgz",
"integrity": "sha512-P5x4yNhcdkYsCEoYeGZP8Q9Jlxf0WXJa4G/xvbmM905seZc9FqJqvCSRvX3dWTPOXRABhl4g+8DHqfft0c/AvQ==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@tanstack/history": "1.95.0",
"@tanstack/react-store": "^0.7.0",
@@ -5731,7 +5739,6 @@
"integrity": "sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"@babel/code-frame": "^7.10.4",
"@babel/runtime": "^7.12.5",
@@ -5752,7 +5759,6 @@
"integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==",
"dev": true,
"license": "Apache-2.0",
- "peer": true,
"dependencies": {
"dequal": "^2.0.3"
}
@@ -5763,7 +5769,6 @@
"integrity": "sha512-zIcONa+hVtVSSep9UT3jZ5rizo2BsxgyDYU7WFD5eICBE7no3881HGeb/QkGfsJs6JTkY1aQhT7rIPC7e+0nnA==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"@adobe/css-tools": "^4.4.0",
"aria-query": "^5.0.0",
@@ -5783,8 +5788,7 @@
"resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.6.3.tgz",
"integrity": "sha512-7ZgogeTnjuHbo+ct10G9Ffp0mif17idi0IyWNVA/wcwcm7NPOD/WEHVP3n7n3MhXqxoIYm8d6MuZohYWIZ4T3w==",
"dev": true,
- "license": "MIT",
- "peer": true
+ "license": "MIT"
},
"node_modules/@testing-library/user-event": {
"version": "14.6.1",
@@ -5792,7 +5796,6 @@
"integrity": "sha512-vq7fv0rnt+QTXgPxr5Hjc210p6YKq2kmdziLgnsZGgLJ9e6VAShx1pACLuRjd/AS/sr7phAR58OIIpf0LlmQNw==",
"dev": true,
"license": "MIT",
- "peer": true,
"engines": {
"node": ">=12",
"npm": ">=6"
@@ -5806,8 +5809,7 @@
"resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz",
"integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==",
"dev": true,
- "license": "MIT",
- "peer": true
+ "license": "MIT"
},
"node_modules/@types/babel__core": {
"version": "7.20.5",
@@ -5860,7 +5862,6 @@
"integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"@types/deep-eql": "*",
"assertion-error": "^2.0.1"
@@ -5982,8 +5983,7 @@
"resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz",
"integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==",
"dev": true,
- "license": "MIT",
- "peer": true
+ "license": "MIT"
},
"node_modules/@types/doctrine": {
"version": "0.0.9",
@@ -6058,6 +6058,15 @@
"undici-types": "~6.20.0"
}
},
+ "node_modules/@types/node-forge": {
+ "version": "1.3.14",
+ "resolved": "https://registry.npmjs.org/@types/node-forge/-/node-forge-1.3.14.tgz",
+ "integrity": "sha512-mhVF2BnD4BO+jtOp7z1CdzaK4mbuK0LLQYAvdOLqHTavxFNq4zA1EmYkpnFjP8HOUzedfQkRnp0E2ulSAYSzAw==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/node": "*"
+ }
+ },
"node_modules/@types/nprogress": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/@types/nprogress/-/nprogress-0.2.3.tgz",
@@ -6098,6 +6107,7 @@
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.16.tgz",
"integrity": "sha512-oh8AMIC4Y2ciKufU8hnKgs+ufgbA/dhPTACaZPM86AbwX9QwnFtSoPWEeRUj8fge+v6kFt78BXcDhAU1SrrAsw==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@types/prop-types": "*",
"csstype": "^3.0.2"
@@ -6109,6 +6119,7 @@
"integrity": "sha512-P4t6saawp+b/dFrUr2cvkVsfvPguwsxtH6dNIYRllMsefqFzkZk5UIjzyDOv5g1dXIPdG4Sp1yCR4Z6RCUsG/Q==",
"devOptional": true,
"license": "MIT",
+ "peer": true,
"peerDependencies": {
"@types/react": "^18.0.0"
}
@@ -6162,6 +6173,7 @@
"integrity": "sha512-QXwAlHlbcAwNlEEMKQS2RCgJsgXrTJdjXT08xEgbPFa2yYQgVjBymxP5DrfrE7X7iodSzd9qBUHUycdyVJTW1w==",
"dev": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"@eslint-community/regexpp": "^4.10.0",
"@typescript-eslint/scope-manager": "8.34.0",
@@ -6202,6 +6214,7 @@
"integrity": "sha512-vxXJV1hVFx3IXz/oy2sICsJukaBrtDEQSBiV48/YIV5KWjX1dO+bcIr/kCPrW6weKXvsaGKFNlwH0v2eYdRRbA==",
"dev": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"@typescript-eslint/scope-manager": "8.34.0",
"@typescript-eslint/types": "8.34.0",
@@ -6447,7 +6460,6 @@
"integrity": "sha512-Io0yyORnB6sikFlt8QW5K7slY4OjqNX9jmJQ02QDda8lyM6B5oNgVWoSoKPac8/kgnCUzuHQKrSLtu/uOqqrig==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"@types/chai": "^5.2.2",
"@vitest/spy": "3.2.4",
@@ -6465,7 +6477,6 @@
"integrity": "sha512-46ryTE9RZO/rfDd7pEqFl7etuyzekzEhUbTW3BvmeO/BcCMEgq59BKhek3dXDWgAj4oMK6OZi+vRr1wPW6qjEQ==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"@vitest/spy": "3.2.4",
"estree-walker": "^3.0.3",
@@ -6493,7 +6504,6 @@
"integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"@types/estree": "^1.0.0"
}
@@ -6504,7 +6514,6 @@
"integrity": "sha512-IVNZik8IVRJRTr9fxlitMKeJeXFFFN0JaB9PHPGQ8NKQbGpfjlTx9zO4RefN8gp7eqjNy8nyK3NZmBzOPeIxtA==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"tinyrainbow": "^2.0.0"
},
@@ -6518,7 +6527,6 @@
"integrity": "sha512-vAfasCOe6AIK70iP5UD11Ac4siNUNJ9i/9PZ3NKx07sG6sUxeag1LWdNrMWeKKYBLlzuK+Gn65Yd5nyL6ds+nw==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"tinyspy": "^4.0.3"
},
@@ -6532,7 +6540,6 @@
"integrity": "sha512-fB2V0JFrQSMsCo9HiSq3Ezpdv4iYaXRG1Sx8edX3MwxfyNn83mKiGzOcH+Fkxt4MHxr3y42fQi1oeAInqgX2QA==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"@vitest/pretty-format": "3.2.4",
"loupe": "^3.1.4",
@@ -6561,7 +6568,8 @@
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/@xterm/xterm/-/xterm-5.5.0.tgz",
"integrity": "sha512-hqJHYaQb5OptNunnyAnkHyM8aCjZ1MEIDTQu1iIbbTD/xops91NB5yq1ZK/dC2JDbVWtF23zUtl9JE2NqwT87A==",
- "license": "MIT"
+ "license": "MIT",
+ "peer": true
},
"node_modules/@xyflow/react": {
"version": "12.4.4",
@@ -6627,6 +6635,7 @@
"integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==",
"dev": true,
"license": "MIT",
+ "peer": true,
"bin": {
"acorn": "bin/acorn"
},
@@ -6749,7 +6758,6 @@
"integrity": "sha512-COROpnaoap1E2F000S62r6A60uHZnmlvomhfyT2DlTcrY1OrBKn2UhH7qn5wTC9zMvD0AY7csdPSNwKP+7WiQw==",
"dev": true,
"license": "Apache-2.0",
- "peer": true,
"engines": {
"node": ">= 0.4"
}
@@ -6798,7 +6806,6 @@
"integrity": "sha512-CVvd6FHg1Z3POpBLxO6E6zr+rSKEQ9L6rZHAaY7lLfhKsWYUBBOuMs0e9o24oopj6H+geRCX0YJ+TJLBK2eHyQ==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"call-bind": "^1.0.7",
"define-properties": "^1.2.1",
@@ -6879,7 +6886,6 @@
"integrity": "sha512-p6Fx8B7b7ZhL/gmUsAy0D15WhvDccw3mnGNbZpi3pmeJdxtWsj2jEaI4Y6oo3XiHfzuSgPwKc04MYt6KgvC/wA==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"call-bind": "^1.0.7",
"define-properties": "^1.2.1",
@@ -6967,7 +6973,6 @@
"integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==",
"dev": true,
"license": "MIT",
- "peer": true,
"engines": {
"node": ">=12"
}
@@ -6978,7 +6983,6 @@
"integrity": "sha512-6t10qk83GOG8p0vKmaCr8eiilZwO171AvbROMtvvNiwrTly62t+7XkA8RdIIVbpMhCASAsxgAzdRSwh6nw/5Dg==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"tslib": "^2.0.1"
},
@@ -6991,8 +6995,7 @@
"resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.8.tgz",
"integrity": "sha512-OH/2E5Fg20h2aPrbe+QL8JZQFko0YZaF+j4mnQ7BGhfavO7OpSLa8a0y9sBwomHdSbkhTS8TQNayBfnW5DwbvQ==",
"dev": true,
- "license": "MIT",
- "peer": true
+ "license": "MIT"
},
"node_modules/asynckit": {
"version": "0.4.0",
@@ -7044,7 +7047,6 @@
"integrity": "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==",
"dev": true,
"license": "Apache-2.0",
- "peer": true,
"engines": {
"node": ">= 0.4"
}
@@ -7130,7 +7132,6 @@
"integrity": "sha512-aVNobHnJqLiUelTaHat9DZ1qM2w0C0Eym4LPI/3JxOnSokGVdsl1T1kN7TFvsEAD8G47A6VKQ0TVHqbBnYMJlQ==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"open": "^8.0.4"
},
@@ -7351,6 +7352,7 @@
}
],
"license": "MIT",
+ "peer": true,
"dependencies": {
"baseline-browser-mapping": "^2.8.9",
"caniuse-lite": "^1.0.30001746",
@@ -7507,7 +7509,6 @@
"integrity": "sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"assertion-error": "^2.0.1",
"check-error": "^2.1.1",
@@ -7578,7 +7579,6 @@
"integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==",
"dev": true,
"license": "MIT",
- "peer": true,
"engines": {
"node": ">= 16"
}
@@ -7651,12 +7651,6 @@
"integrity": "sha512-JhZUT7JFcQy/EzW605k/ktHtncoo9vnyW/2GspNYwFlN1C/WmjuV/xtS04e9SOkL2sTdw0VAZ2UGCcQ9lR6p6w==",
"license": "MIT"
},
- "node_modules/classnames": {
- "version": "2.5.1",
- "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.5.1.tgz",
- "integrity": "sha512-saHYOzhIQs6wy2sVxTM6bUDsQO4F50V9RQ22qBpEdCW+I+/Wmke2HOl6lS6dTpdxVhb88/I6+Hs+438c3lfUow==",
- "license": "MIT"
- },
"node_modules/client-only": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/client-only/-/client-only-0.0.1.tgz",
@@ -8408,8 +8402,7 @@
"resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz",
"integrity": "sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==",
"dev": true,
- "license": "MIT",
- "peer": true
+ "license": "MIT"
},
"node_modules/csstype": {
"version": "3.1.3",
@@ -8533,6 +8526,7 @@
"resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz",
"integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==",
"license": "ISC",
+ "peer": true,
"engines": {
"node": ">=12"
}
@@ -8622,8 +8616,7 @@
"resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz",
"integrity": "sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==",
"dev": true,
- "license": "BSD-2-Clause",
- "peer": true
+ "license": "BSD-2-Clause"
},
"node_modules/data-view-buffer": {
"version": "1.0.1",
@@ -8745,7 +8738,6 @@
"integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==",
"dev": true,
"license": "MIT",
- "peer": true,
"engines": {
"node": ">=6"
}
@@ -8781,7 +8773,6 @@
"integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==",
"dev": true,
"license": "MIT",
- "peer": true,
"engines": {
"node": ">=8"
}
@@ -8912,8 +8903,7 @@
"resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz",
"integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==",
"dev": true,
- "license": "MIT",
- "peer": true
+ "license": "MIT"
},
"node_modules/dom-helpers": {
"version": "5.2.1",
@@ -9133,7 +9123,6 @@
"integrity": "sha512-tpxqxncxnpw3c93u8n3VOzACmRFoVmWJqbWXvX/JfKbkhBw1oslgPrUfeSt2psuqyEJFD6N/9lg5i7bsKpoq+Q==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"call-bind": "^1.0.7",
"define-properties": "^1.2.1",
@@ -9227,6 +9216,7 @@
"dev": true,
"hasInstallScript": true,
"license": "MIT",
+ "peer": true,
"bin": {
"esbuild": "bin/esbuild"
},
@@ -9268,7 +9258,6 @@
"integrity": "sha512-H2/S7Pm8a9CL1uhp9OvjwrBh5Pvx0H8qVOxNu8Wed9Y7qv56MPtq+GGM8RJpq6glYJn9Wspr8uw7l55uyinNeg==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"debug": "^4.3.4"
},
@@ -9305,6 +9294,7 @@
"deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.",
"dev": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@eslint-community/regexpp": "^4.6.1",
@@ -9361,6 +9351,7 @@
"integrity": "sha512-T75QYQVQX57jiNgpF9r1KegMICE94VYwoFQyMGhrvc+lB8YF2E/M/PYDaQe1AJcWaEgqLE+ErXV1Og/+6Vyzew==",
"dev": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"eslint-config-airbnb-base": "^15.0.0",
"object.assign": "^4.1.2",
@@ -9383,6 +9374,7 @@
"integrity": "sha512-xaX3z4ZZIcFLvh2oUNvcX5oEofXda7giYmuplVxoOg5A7EXJMrUyqRgR+mhDhPK8LZ4PttFOBvCYDbX3sUoUig==",
"dev": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"confusing-browser-globals": "^1.0.10",
"object.assign": "^4.1.2",
@@ -9413,6 +9405,7 @@
"integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==",
"dev": true,
"license": "MIT",
+ "peer": true,
"bin": {
"eslint-config-prettier": "bin/cli.js"
},
@@ -9512,6 +9505,7 @@
"integrity": "sha512-ixmkI62Rbc2/w8Vfxyh1jQRTdRTF52VxwRVHl/ykPAmqG+Nb7/kNn+byLP0LxPgI7zWA16Jt82SybJInmMia3A==",
"dev": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"@rtsao/scc": "^1.1.0",
"array-includes": "^3.1.8",
@@ -9603,7 +9597,6 @@
"integrity": "sha512-scB3nz4WmG75pV8+3eRUQOHZlNSUhFNq37xnpgRkCCELU3XMvXAxLk1eqWWyE22Ki4Q01Fnsw9BA3cJHDPgn2Q==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"aria-query": "^5.3.2",
"array-includes": "^3.1.8",
@@ -9634,7 +9627,6 @@
"integrity": "sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -9646,7 +9638,6 @@
"integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==",
"dev": true,
"license": "ISC",
- "peer": true,
"dependencies": {
"brace-expansion": "^1.1.7"
},
@@ -9691,7 +9682,6 @@
"integrity": "sha512-EsTAnj9fLVr/GZleBLFbj/sSuXeWmp1eXIN60ceYnZveqEaUCyW4X+Vh4WTdUhCkW4xutXYqTXCUSyqD4rB75w==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"array-includes": "^3.1.8",
"array.prototype.findlast": "^1.2.5",
@@ -9725,6 +9715,7 @@
"integrity": "sha512-QzliNJq4GinDBcD8gPB5v0wh6g8q3SUi6EFF0x8N/BL9PoVs0atuGc47ozMRyOWAKdwaZ5OnbOEa3WR+dSGKuQ==",
"dev": true,
"license": "MIT",
+ "peer": true,
"engines": {
"node": ">=10"
},
@@ -9748,7 +9739,6 @@
"integrity": "sha512-MWPGfDxnyzKU7rNOW9SP/c50vi3xrmrua/+6hfPbCS2ABNWfx24vPidzvC7krjU/RTo235sV776ymlsMtGKj8g==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -9760,7 +9750,6 @@
"integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==",
"dev": true,
"license": "Apache-2.0",
- "peer": true,
"dependencies": {
"esutils": "^2.0.2"
},
@@ -9774,7 +9763,6 @@
"integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==",
"dev": true,
"license": "ISC",
- "peer": true,
"dependencies": {
"brace-expansion": "^1.1.7"
},
@@ -9788,7 +9776,6 @@
"integrity": "sha512-U7WjGVG9sH8tvjW5SmGbQuui75FiyjAX72HX15DwBBwF9dNiQZRQAg9nnPhYy+TUnE0+VcrttuvNI8oSxZcocA==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"is-core-module": "^2.13.0",
"path-parse": "^1.0.7",
@@ -9807,7 +9794,6 @@
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
"dev": true,
"license": "ISC",
- "peer": true,
"bin": {
"semver": "bin/semver.js"
}
@@ -9993,7 +9979,6 @@
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
"dev": true,
"license": "BSD-2-Clause",
- "peer": true,
"bin": {
"esparse": "bin/esparse.js",
"esvalidate": "bin/esvalidate.js"
@@ -10966,6 +10951,7 @@
}
],
"license": "MIT",
+ "peer": true,
"dependencies": {
"@babel/runtime": "^7.23.2"
},
@@ -11023,6 +11009,7 @@
"resolved": "https://registry.npmjs.org/immer/-/immer-10.2.0.tgz",
"integrity": "sha512-d/+XTN3zfODyjr89gM3mPq1WNX2B8pYsu7eORitdwyA2sBubnTl3laYlBk4sXY5FUa5qTZGBDPJICVbvqzjlbw==",
"license": "MIT",
+ "peer": true,
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/immer"
@@ -11060,7 +11047,6 @@
"integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==",
"dev": true,
"license": "MIT",
- "peer": true,
"engines": {
"node": ">=8"
}
@@ -11333,7 +11319,6 @@
"integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==",
"dev": true,
"license": "MIT",
- "peer": true,
"bin": {
"is-docker": "cli.js"
},
@@ -11656,7 +11641,6 @@
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"is-docker": "^2.0.0"
},
@@ -11692,7 +11676,6 @@
"resolved": "https://registry.npmjs.org/isomorphic.js/-/isomorphic.js-0.2.5.tgz",
"integrity": "sha512-PIeMbHqMt4DnUP3MA/Flc0HElYjMXArsw1qwJZcm9sqR8mq3l8NYizFMty0pWwE/tzIGH3EKK5+jes5mAr85yw==",
"license": "MIT",
- "peer": true,
"funding": {
"type": "GitHub Sponsors ❤",
"url": "https://github.com/sponsors/dmonad"
@@ -11704,7 +11687,6 @@
"integrity": "sha512-x4WH0BWmrMmg4oHHl+duwubhrvczGlyuGAZu3nvrf0UXOfPu8IhZObFEr7DE/iv01YgVZrsOiRcqw2srkKEDIA==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"define-data-property": "^1.1.4",
"es-object-atoms": "^1.0.0",
@@ -11820,7 +11802,6 @@
"integrity": "sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"array-includes": "^3.1.6",
"array.prototype.flat": "^1.3.1",
@@ -11855,8 +11836,7 @@
"resolved": "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.23.tgz",
"integrity": "sha512-0K65Lea881pHotoGEa5gDlMxt3pctLi2RplBb7Ezh4rRdLEOtgi7n4EwK9lamnUCkKBqaeKRVebTq6BAxSkpXQ==",
"dev": true,
- "license": "CC0-1.0",
- "peer": true
+ "license": "CC0-1.0"
},
"node_modules/language-tags": {
"version": "1.0.9",
@@ -11864,7 +11844,6 @@
"integrity": "sha512-MbjN408fEndfiQXbFQ1vnd+1NoLDsnQW41410oQBXiyXDMYH5z505juWa4KUE1LqxRC7DgOgZDbKLxHIwm27hA==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"language-subtag-registry": "^0.3.20"
},
@@ -11897,7 +11876,6 @@
"resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.102.tgz",
"integrity": "sha512-g70kydI0I1sZU0ChO8mBbhw0oUW/8U0GHzygpvEIx8k+jgOpqnTSb/E+70toYVqHxBhrERD21TwD5QcZJQ40ZQ==",
"license": "MIT",
- "peer": true,
"dependencies": {
"isomorphic.js": "^0.2.4"
},
@@ -12214,8 +12192,7 @@
"resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.1.tgz",
"integrity": "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==",
"dev": true,
- "license": "MIT",
- "peer": true
+ "license": "MIT"
},
"node_modules/lru-cache": {
"version": "5.1.1",
@@ -12242,7 +12219,6 @@
"integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==",
"dev": true,
"license": "MIT",
- "peer": true,
"bin": {
"lz-string": "bin/bin.js"
}
@@ -12936,7 +12912,6 @@
"integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==",
"dev": true,
"license": "MIT",
- "peer": true,
"engines": {
"node": ">=4"
}
@@ -13068,6 +13043,15 @@
}
}
},
+ "node_modules/node-forge": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.4.0.tgz",
+ "integrity": "sha512-LarFH0+6VfriEhqMMcLX2F7SwSXeWwnEAJEsYm5QKWchiVYVvJyV9v7UDvUv+w5HO23ZpQTXDv/GxdDdMyOuoQ==",
+ "license": "(BSD-3-Clause OR GPL-2.0)",
+ "engines": {
+ "node": ">= 6.13.0"
+ }
+ },
"node_modules/node-releases": {
"version": "2.0.26",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.26.tgz",
@@ -13288,7 +13272,6 @@
"integrity": "sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"define-lazy-prop": "^2.0.0",
"is-docker": "^2.1.1",
@@ -13518,7 +13501,6 @@
"integrity": "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==",
"dev": true,
"license": "MIT",
- "peer": true,
"engines": {
"node": ">= 14.16"
}
@@ -13673,6 +13655,7 @@
"integrity": "sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==",
"dev": true,
"license": "MIT",
+ "peer": true,
"bin": {
"prettier": "bin/prettier.cjs"
},
@@ -13789,7 +13772,6 @@
"integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"ansi-regex": "^5.0.1",
"ansi-styles": "^5.0.0",
@@ -13805,7 +13787,6 @@
"integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==",
"dev": true,
"license": "MIT",
- "peer": true,
"engines": {
"node": ">=10"
},
@@ -13818,8 +13799,7 @@
"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==",
"dev": true,
- "license": "MIT",
- "peer": true
+ "license": "MIT"
},
"node_modules/prismjs": {
"version": "1.30.0",
@@ -14058,6 +14038,7 @@
"resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz",
"integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"loose-envify": "^1.1.0"
},
@@ -14145,6 +14126,7 @@
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz",
"integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"loose-envify": "^1.1.0",
"scheduler": "^0.23.2"
@@ -14195,6 +14177,7 @@
"resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.56.3.tgz",
"integrity": "sha512-IK18V6GVbab4TAo1/cz3kqajxbDPGofdF0w7VHdCo0Nt8PrPlOZcuuDq9YYIV1BtjcX78x0XsldbQRQnQXWXmw==",
"license": "MIT",
+ "peer": true,
"engines": {
"node": ">=18.0.0"
},
@@ -14241,7 +14224,8 @@
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==",
- "license": "MIT"
+ "license": "MIT",
+ "peer": true
},
"node_modules/react-markdown": {
"version": "10.0.1",
@@ -14274,6 +14258,7 @@
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.2.0.tgz",
"integrity": "sha512-ROY9fvHhwOD9ySfrF0wmvu//bKCQ6AeZZq1nJNtbDC+kk5DuSuNX/n6YWYF/SYy7bSba4D4FSz8DJeKY/S/r+g==",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@types/use-sync-external-store": "^0.0.6",
"use-sync-external-store": "^1.4.0"
@@ -14454,7 +14439,6 @@
"integrity": "sha512-YTUo+Flmw4ZXiWfQKGcwwc11KnoRAYgzAE2E7mXKCjSviTKShtxBsN6YUUBB2gtaBzKzeKunxhUwNHQuRryhWA==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"ast-types": "^0.16.1",
"esprima": "~4.0.0",
@@ -14472,7 +14456,6 @@
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true,
"license": "BSD-3-Clause",
- "peer": true,
"engines": {
"node": ">=0.10.0"
}
@@ -14513,7 +14496,6 @@
"integrity": "sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"indent-string": "^4.0.0",
"strip-indent": "^3.0.0"
@@ -14528,7 +14510,6 @@
"integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"min-indent": "^1.0.0"
},
@@ -14540,7 +14521,8 @@
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz",
"integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w==",
- "license": "MIT"
+ "license": "MIT",
+ "peer": true
},
"node_modules/redux-thunk": {
"version": "3.1.0",
@@ -14810,6 +14792,7 @@
"integrity": "sha512-VmtB2rFU/GroZ4oL8+ZqXgSA38O6GR8KSIvWmEFv63pQ0G6KaBH9s07PO8XTXP4vI+3UJUEypOfjkGfmSBBR0w==",
"dev": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"@types/estree": "1.0.8"
},
@@ -15324,7 +15307,6 @@
"integrity": "sha512-o7+c9bW6zpAdJHTtujeePODAhkuicdAryFsfVKwA+wGw89wJ4GTY484WTucM9hLtDEOpOvI+aHnzqnC5lHp4Rg==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"call-bind": "^1.0.7",
"define-properties": "^1.2.1",
@@ -15340,7 +15322,6 @@
"integrity": "sha512-NUdh0aDavY2og7IbBPenWqR9exH+E26Sv8e0/eTe1tltDGZL+GtBkDAnnyBtmekfK6/Dq3MkcGtzXFEd1LQrtg==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"call-bind": "^1.0.7",
"define-properties": "^1.2.1",
@@ -15368,7 +15349,6 @@
"integrity": "sha512-0u/TldDbKD8bFCQ/4f5+mNRrXwZ8hg2w7ZR8wa16e8z9XpePWl3eGEcUD0OXpEH/VJH/2G3gjUtR3ZOiBe2S/w==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"define-properties": "^1.1.3",
"es-abstract": "^1.17.5"
@@ -15679,7 +15659,6 @@
"integrity": "sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==",
"dev": true,
"license": "MIT",
- "peer": true,
"engines": {
"node": ">=14.0.0"
}
@@ -15690,7 +15669,6 @@
"integrity": "sha512-azl+t0z7pw/z958Gy9svOTuzqIk6xq+NSheJzn5MMWtWTFywIacg2wUlzKFGtt3cthx0r2SxMK0yzJOR0IES7Q==",
"dev": true,
"license": "MIT",
- "peer": true,
"engines": {
"node": ">=14.0.0"
}
@@ -15975,6 +15953,7 @@
"integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==",
"devOptional": true,
"license": "Apache-2.0",
+ "peer": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
@@ -16366,6 +16345,7 @@
"integrity": "sha512-2N/55r4JDJ4gdrCvGgINMy+HH3iRpNIz8K6SFwVsA+JbQScLiC+clmAxBgwiSPgcG9U15QmvqCGWzMbqda5zGQ==",
"dev": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"esbuild": "^0.25.0",
"fdir": "^6.4.4",
@@ -16789,7 +16769,6 @@
"integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==",
"dev": true,
"license": "MIT",
- "peer": true,
"engines": {
"node": ">=10.0.0"
},
@@ -16866,6 +16845,7 @@
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.3.tgz",
"integrity": "sha512-AvbaCLOO2Otw/lW5bmh9d/WEdcDFdQp2Z2ZUH3pX9U2ihyUY0nvLv7J6TrWowklRGPYbB/IuIMfYgxaCPg5Bpg==",
"license": "ISC",
+ "peer": true,
"bin": {
"yaml": "bin.mjs"
},
@@ -17019,6 +16999,7 @@
"resolved": "https://registry.npmjs.org/zod/-/zod-3.24.1.tgz",
"integrity": "sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==",
"license": "MIT",
+ "peer": true,
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}
diff --git a/frontend/package.json b/frontend/package.json
index 2d1ea8db21..d81211cf59 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -94,6 +94,7 @@
"@tanstack/virtual-file-routes": "^1.87.6",
"@tanstack/zod-adapter": "^1.91.0",
"@types/dagre": "^0.7.52",
+ "@types/node-forge": "^1.3.14",
"@types/nprogress": "^0.2.3",
"@ucast/mongo2js": "^1.3.4",
"@xterm/addon-fit": "^0.10.0",
@@ -115,6 +116,7 @@
"lexical": "^0.29.0",
"lucide-react": "^0.544.0",
"ms": "^2.1.3",
+ "node-forge": "^1.4.0",
"nprogress": "^0.2.0",
"picomatch": "^4.0.4",
"posthog-js": "^1.360.1",
diff --git a/backend/src/services/certificate/certificate-pkcs12-fns.ts b/frontend/src/helpers/pkcs12.ts
similarity index 52%
rename from backend/src/services/certificate/certificate-pkcs12-fns.ts
rename to frontend/src/helpers/pkcs12.ts
index 65b4a09101..ffbb0019ff 100644
--- a/backend/src/services/certificate/certificate-pkcs12-fns.ts
+++ b/frontend/src/helpers/pkcs12.ts
@@ -1,24 +1,20 @@
-import crypto from "node:crypto";
-
import * as x509 from "@peculiar/x509";
import forge from "node-forge";
-import RE2 from "re2";
-// The extraction worker imports this module directly, and in development Node strips its types
-// without a compiler: no enums or other non-erasable TypeScript anywhere this module reaches.
-export const Pkcs12ErrorCode = {
+const Pkcs12ErrorCode = {
NotAKeystore: "not_a_keystore",
BadPassword: "bad_password",
UnsupportedEntries: "unsupported_entries",
- TooManyBags: "too_many_bags",
+ TooManyKeys: "too_many_keys",
+ TooManyCertificates: "too_many_certificates",
TooExpensive: "too_expensive",
NoEntries: "no_entries",
NoPairs: "no_pairs"
} as const;
-export type TPkcs12ErrorCode = (typeof Pkcs12ErrorCode)[keyof typeof Pkcs12ErrorCode];
+type TPkcs12ErrorCode = (typeof Pkcs12ErrorCode)[keyof typeof Pkcs12ErrorCode];
-export class Pkcs12ExtractionError extends Error {
+class Pkcs12ExtractionError extends Error {
code: TPkcs12ErrorCode;
count?: number;
@@ -30,12 +26,12 @@ export class Pkcs12ExtractionError extends Error {
}
}
-type TPkcs12Entry = {
+export type TPkcs12Entry = {
alias: string | null;
subject: string;
commonName: string | null;
altNames: string | null;
- keyAlgorithm: string;
+ keyAlgorithm?: string;
notAfter: string;
fingerprintSha256: string;
chainWarning: string | null;
@@ -44,39 +40,41 @@ type TPkcs12Entry = {
privateKeyPem?: string;
};
-export type TExtractPkcs12Result = {
- entries: TPkcs12Entry[];
-};
-
const MAX_KEY_BAGS = 8;
const MAX_CERT_BAGS = 100;
const MAX_CHAIN_DEPTH = 10;
-const CHAIN_WARNING = "No usable issuer chain was found in the keystore, so this will be imported on its own.";
+const CHAIN_WARNING =
+ "No issuer chain was found in the keystore. This certificate will be imported on its own.";
const MAX_SUBJECT_LENGTH = 2048;
const MAX_ALIAS_LENGTH = 1024;
-const toPem = (type: string, derBytes: string) => forge.pem.encode({ type, body: derBytes });
+const derBytes = (der: string) => Uint8Array.from(der, (char) => char.charCodeAt(0));
-const bagAttribute = (bag: forge.pkcs12.Bag, name: "friendlyName" | "localKeyId"): string | null => {
+// forge writes CRLF line endings, which @peculiar/x509 refuses to parse.
+const toPem = (type: string, der: string) =>
+ forge.pem.encode({ type, body: der }).replace(/\r\n/g, "\n");
+
+const bagAttribute = (
+ bag: forge.pkcs12.Bag,
+ name: "friendlyName" | "localKeyId"
+): string | null => {
const values = (bag.attributes as Record<string, string[] | undefined>)[name];
return values?.length ? values[0] : null;
};
// forge leaves `bag.key` / `bag.cert` null for anything non-RSA and hands back the decrypted ASN.1
// instead, so never consume its parsed objects: the ASN.1 is what makes EC, Ed25519 and PQC work.
-const certBagToPem = (bag: forge.pkcs12.Bag) => {
+const certBagToDer = (bag: forge.pkcs12.Bag) => {
const asn1 = bag.cert ? forge.pki.certificateToAsn1(bag.cert) : bag.asn1;
if (!asn1) return null;
- return toPem("CERTIFICATE", forge.asn1.toDer(asn1).getBytes());
+ return forge.asn1.toDer(asn1).getBytes();
};
-const keyBagToPem = (bag: forge.pkcs12.Bag) => {
- const asn1 = bag.asn1 ?? (bag.key ? forge.pki.wrapRsaPrivateKey(forge.pki.privateKeyToAsn1(bag.key)) : null);
- if (!asn1) return null;
- return toPem("PRIVATE KEY", forge.asn1.toDer(asn1).getBytes());
-};
+// forge parses RSA into `bag.key` and leaves the ASN.1 unset, so it is rebuilt for those.
+const keyBagAsn1 = (bag: forge.pkcs12.Bag) =>
+ bag.asn1 ?? (bag.key ? forge.pki.wrapRsaPrivateKey(forge.pki.privateKeyToAsn1(bag.key)) : null);
const readAltNames = (cert: x509.X509Certificate) => {
const extension = cert.extensions.find((ext) => ext.type === "2.5.29.17");
@@ -93,9 +91,11 @@ const readAltNames = (cert: x509.X509Certificate) => {
}
};
-const sha256Fingerprint = (der: Buffer) => {
- const hex = crypto.createHash("sha256").update(der).digest("hex").toUpperCase();
- return new RE2(".{2}", "g").match(hex)?.join(":") ?? hex;
+const sha256Fingerprint = async (der: ArrayBuffer) => {
+ const digest = await crypto.subtle.digest("SHA-256", der);
+ return [...new Uint8Array(digest)]
+ .map((byte) => byte.toString(16).padStart(2, "0").toUpperCase())
+ .join(":");
};
type TParsedCert = {
@@ -108,72 +108,112 @@ type TParsedCert = {
type TParsedKey = {
pem: string;
- spki: string;
keyAlgorithm: string;
localKeyId: string | null;
friendlyName: string | null;
};
const EC_CURVE_LABELS: Record<string, string> = {
- prime256v1: "P-256",
- secp384r1: "P-384",
- secp521r1: "P-521",
- secp256k1: "secp256k1"
+ "1.2.840.10045.3.1.7": "P-256",
+ "1.3.132.0.34": "P-384",
+ "1.3.132.0.35": "P-521",
+ "1.3.132.0.10": "secp256k1"
};
-const describeKey = (key: crypto.KeyObject) => {
- const type = key.asymmetricKeyType ?? "unknown";
- const details = key.asymmetricKeyDetails;
+const KEY_ALGORITHM_LABELS: Record<string, string> = {
+ "1.3.101.112": "Ed25519",
+ "1.3.101.113": "Ed448",
+ "2.16.840.1.101.3.4.3.17": "ML-DSA-44",
+ "2.16.840.1.101.3.4.3.18": "ML-DSA-65",
+ "2.16.840.1.101.3.4.3.19": "ML-DSA-87"
+};
+
+const RSA_OIDS = new Set(["1.2.840.113549.1.1.1", "1.2.840.113549.1.1.10"]);
+const EC_OID = "1.2.840.10045.2.1";
+
+// The browser has no equivalent of Node's key inspection, so the algorithm is read straight out of
+// the PrivateKeyInfo: an OID, and for RSA a modulus whose length is the key size.
+const describeKey = (keyAsn1: forge.asn1.Asn1) => {
+ if (!Array.isArray(keyAsn1.value)) return "";
+ const algorithm = keyAsn1.value[1];
+ if (!Array.isArray(algorithm?.value)) return "";
- if (type === "rsa" || type === "rsa-pss") {
- return details?.modulusLength ? `RSA ${details.modulusLength}` : "RSA";
+ const [oidNode, paramNode] = algorithm.value;
+ if (oidNode?.type !== forge.asn1.Type.OID || typeof oidNode.value !== "string") return "";
+ const oid = forge.asn1.derToOid(oidNode.value);
+
+ if (RSA_OIDS.has(oid)) {
+ const keyBytes = keyAsn1.value[2];
+ if (typeof keyBytes?.value !== "string") return "RSA";
+ try {
+ const inner = forge.asn1.fromDer(keyBytes.value);
+ const modulus = Array.isArray(inner.value) ? inner.value[1] : null;
+ if (typeof modulus?.value !== "string") return "RSA";
+ // A leading zero byte keeps the modulus positive and is not part of the key size.
+ const bytes =
+ modulus.value.charCodeAt(0) === 0 ? modulus.value.length - 1 : modulus.value.length;
+ return `RSA ${bytes * 8}`;
+ } catch {
+ return "RSA";
+ }
}
- if (type === "ec") {
- const curve = details?.namedCurve;
- return `ECDSA ${curve ? (EC_CURVE_LABELS[curve] ?? curve) : ""}`.trim();
+
+ if (oid === EC_OID) {
+ if (paramNode?.type === forge.asn1.Type.OID && typeof paramNode.value === "string") {
+ const curve = forge.asn1.derToOid(paramNode.value);
+ return `ECDSA ${EC_CURVE_LABELS[curve] ?? curve}`;
+ }
+ return "ECDSA";
}
- if (type === "ed25519") return "Ed25519";
- if (type === "ed448") return "Ed448";
- if (type === "unknown") return "";
- return type.toUpperCase();
+
+ return KEY_ALGORITHM_LABELS[oid] ?? "";
};
const readBags = (p12: forge.pkcs12.Pkcs12Pfx) => {
const certBags = p12.getBags({ bagType: forge.pki.oids.certBag })[forge.pki.oids.certBag] ?? [];
const shrouded =
- p12.getBags({ bagType: forge.pki.oids.pkcs8ShroudedKeyBag })[forge.pki.oids.pkcs8ShroudedKeyBag] ?? [];
+ p12.getBags({ bagType: forge.pki.oids.pkcs8ShroudedKeyBag })[
+ forge.pki.oids.pkcs8ShroudedKeyBag
+ ] ?? [];
const plain = p12.getBags({ bagType: forge.pki.oids.keyBag })[forge.pki.oids.keyBag] ?? [];
const keyBags = [...shrouded, ...plain];
- if (keyBags.length > MAX_KEY_BAGS) throw new Pkcs12ExtractionError(Pkcs12ErrorCode.TooManyBags, keyBags.length);
- if (certBags.length > MAX_CERT_BAGS) throw new Pkcs12ExtractionError(Pkcs12ErrorCode.TooManyBags, certBags.length);
+ if (keyBags.length > MAX_KEY_BAGS)
+ throw new Pkcs12ExtractionError(Pkcs12ErrorCode.TooManyKeys, keyBags.length);
+ if (certBags.length > MAX_CERT_BAGS)
+ throw new Pkcs12ExtractionError(Pkcs12ErrorCode.TooManyCertificates, certBags.length);
return { certBags, keyBags };
};
-const parseCertBags = (certBags: forge.pkcs12.Bag[]) => {
+const parseCertBags = async (certBags: forge.pkcs12.Bag[]) => {
const byFingerprint = new Map<string, TParsedCert>();
- certBags.forEach((bag) => {
- const pem = certBagToPem(bag);
- if (!pem) return;
+ await Promise.all(
+ certBags.map(async (bag) => {
+ const der = certBagToDer(bag);
+ if (!der) return;
- try {
- const cert = new x509.X509Certificate(pem);
- const fingerprint = sha256Fingerprint(Buffer.from(cert.rawData));
- if (!byFingerprint.has(fingerprint)) {
- byFingerprint.set(fingerprint, {
- pem,
- cert,
- fingerprint,
- localKeyId: bagAttribute(bag, "localKeyId"),
- friendlyName: bagAttribute(bag, "friendlyName")
- });
+ try {
+ // Parsed from DER rather than the PEM text, so the certificate never depends on how the
+ // PEM was formatted.
+ const cert = new x509.X509Certificate(derBytes(der));
+ const pem = toPem("CERTIFICATE", der);
+ const fingerprint = await sha256Fingerprint(cert.rawData);
+ if (!byFingerprint.has(fingerprint)) {
+ byFingerprint.set(fingerprint, {
+ pem,
+ cert,
+ fingerprint,
+ localKeyId: bagAttribute(bag, "localKeyId"),
+ friendlyName: bagAttribute(bag, "friendlyName")
+ });
+ }
+ } catch {
+ // A malformed entry must not fail the rest.
}
- } catch {
- // A malformed entry must not fail the rest.
- }
- });
+ })
+ );
return [...byFingerprint.values()];
};
@@ -182,33 +222,43 @@ const parseKeyBags = (keyBags: forge.pkcs12.Bag[]) => {
const keys: TParsedKey[] = [];
keyBags.forEach((bag) => {
- const pem = keyBagToPem(bag);
- const friendlyName = bagAttribute(bag, "friendlyName");
-
- let spki: string | null = null;
- let keyAlgorithm = "";
- if (pem) {
- try {
- const keyObject = crypto.createPrivateKey(pem);
- spki = crypto.createPublicKey(keyObject).export({ format: "der", type: "spki" }).toString("hex");
- keyAlgorithm = describeKey(keyObject);
- } catch {
- spki = null;
- }
- }
-
- if (pem && spki) {
- keys.push({ pem, spki, keyAlgorithm, localKeyId: bagAttribute(bag, "localKeyId"), friendlyName });
- }
+ const asn1 = keyBagAsn1(bag);
+ if (!asn1) return;
+
+ keys.push({
+ pem: toPem("PRIVATE KEY", forge.asn1.toDer(asn1).getBytes()),
+ keyAlgorithm: describeKey(asn1),
+ localKeyId: bagAttribute(bag, "localKeyId"),
+ friendlyName: bagAttribute(bag, "friendlyName")
+ });
});
return keys;
};
-const findLeafForKey = (key: TParsedKey, certs: TParsedCert[]) => {
- const matches = certs.filter((c) => Buffer.from(c.cert.publicKey.rawData).toString("hex") === key.spki);
- if (matches.length <= 1) return matches[0] ?? null;
- return matches.find((c) => c.localKeyId && c.localKeyId === key.localKeyId) ?? matches[0];
+// A keystore links a key to its certificate with a shared localKeyId, which is what the format
+// provides for exactly this. Where a keystore omits it there is nothing to disambiguate, so a lone
+// key is paired with the lone leaf. importCert verifies the pairing again on the server, so a wrong
+// guess is rejected there rather than stored.
+const findLeafForKey = (
+ key: TParsedKey,
+ keys: TParsedKey[],
+ certs: TParsedCert[],
+ leaves: TParsedCert[]
+) => {
+ if (key.localKeyId) {
+ const tagged = certs.find((cert) => cert.localKeyId === key.localKeyId);
+ if (tagged) return tagged;
+ }
+
+ if (keys.length === 1 && leaves.length === 1) return leaves[0];
+
+ if (key.friendlyName) {
+ const named = certs.find((cert) => cert.friendlyName === key.friendlyName);
+ if (named) return named;
+ }
+
+ return null;
};
// Issuers are matched by signature, not by name: a keystore that has been through a CA renewal
@@ -305,7 +355,11 @@ const declaredKdfRounds = (node: forge.asn1.Asn1, depth = 0): number => {
let total = 0;
const [first, second, third] = children;
- if (first?.type === forge.asn1.Type.OID && typeof first.value === "string" && Array.isArray(second?.value)) {
+ if (
+ first?.type === forge.asn1.Type.OID &&
+ typeof first.value === "string" &&
+ Array.isArray(second?.value)
+ ) {
if (ITERATION_PARAM_OIDS.has(forge.asn1.derToOid(first.value))) {
const count = second.value.find((param) => param.type === forge.asn1.Type.INTEGER);
if (count) total += asn1Integer(count);
@@ -329,16 +383,24 @@ const declaredKdfRounds = (node: forge.asn1.Asn1, depth = 0): number => {
return total;
};
-export const extractPkcs12Entries = async ({
+const binaryString = (bytes: Uint8Array) => {
+ let out = "";
+ for (let i = 0; i < bytes.length; i += 8192) {
+ out += String.fromCharCode(...bytes.subarray(i, i + 8192));
+ }
+ return out;
+};
+
+const extractPkcs12Entries = async ({
pkcs12,
password
}: {
- pkcs12: Buffer;
+ pkcs12: Uint8Array;
password: string;
-}): Promise<TExtractPkcs12Result> => {
+}): Promise<{ entries: TPkcs12Entry[] }> => {
let asn1;
try {
- asn1 = forge.asn1.fromDer(forge.util.createBuffer(pkcs12.toString("binary")));
+ asn1 = forge.asn1.fromDer(forge.util.createBuffer(binaryString(pkcs12)));
} catch {
throw new Pkcs12ExtractionError(Pkcs12ErrorCode.NotAKeystore);
}
@@ -361,7 +423,7 @@ export const extractPkcs12Entries = async ({
}
const { certBags, keyBags } = readBags(p12);
- const certs = parseCertBags(certBags);
+ const certs = await parseCertBags(certBags);
const keys = parseKeyBags(keyBags);
const entries: TPkcs12Entry[] = [];
@@ -384,16 +446,22 @@ export const extractPkcs12Entries = async ({
entries: certs.map((cert) => ({
...describeCert(cert),
alias: cert.friendlyName?.slice(0, MAX_ALIAS_LENGTH) ?? null,
- keyAlgorithm: cert.cert.publicKey.algorithm.name,
chainWarning: null
}))
};
}
+ // A leaf is a certificate that signed nothing else in the file, which is what a keystore holding
+ // one key and its issuers leaves over.
+ const issuerSubjects = new Set(certs.map((cert) => cert.cert.issuer));
+ const leaves = certs.filter(
+ (cert) => !issuerSubjects.has(cert.cert.subject) || cert.cert.subject === cert.cert.issuer
+ );
+
// eslint-disable-next-line no-restricted-syntax
for (const key of keys) {
- const leaf = findLeafForKey(key, certs);
- const pairId = leaf ? `${leaf.fingerprint}:${key.spki}` : null;
+ const leaf = findLeafForKey(key, keys, certs, leaves);
+ const pairId = leaf ? `${leaf.fingerprint}:${key.pem}` : null;
if (leaf && pairId && !seenPairs.has(pairId)) {
seenPairs.add(pairId);
@@ -405,7 +473,9 @@ export const extractPkcs12Entries = async ({
// expired or not yet valid would fail the whole chain. Send the entry on its own instead.
const now = Date.now();
const dateChecked = [leaf, ...chain.slice(0, -1)];
- const anyOutOfDate = dateChecked.some((c) => c.cert.notAfter.getTime() < now || c.cert.notBefore.getTime() > now);
+ const anyOutOfDate = dateChecked.some(
+ (c) => c.cert.notAfter.getTime() < now || c.cert.notBefore.getTime() > now
+ );
const keepChain = chain.length > 0 && !anyOutOfDate && !truncated;
entries.push({
@@ -423,3 +493,40 @@ export const extractPkcs12Entries = async ({
return { entries };
};
+
+const pkcs12ErrorMessage = (code: TPkcs12ErrorCode, count?: number) => {
+ switch (code) {
+ case Pkcs12ErrorCode.NotAKeystore:
+ return "This file is not a valid PKCS#12 keystore. Upload a .p12 or .pfx file.";
+ case Pkcs12ErrorCode.UnsupportedEntries:
+ return "This keystore contains unsupported entry types, such as secret keys. Re-export it with only the certificate and its private key.";
+ case Pkcs12ErrorCode.TooManyKeys:
+ return `This keystore contains ${count ?? "too many"} private keys. Import at most ${MAX_KEY_BAGS} at a time, splitting the keystore if needed.`;
+ case Pkcs12ErrorCode.TooManyCertificates:
+ return `This keystore contains ${count ?? "too many"} certificates. Import at most ${MAX_CERT_BAGS} at a time, splitting the keystore if needed.`;
+ case Pkcs12ErrorCode.TooExpensive:
+ return `This keystore declares more than ${MAX_KDF_ROUNDS.toLocaleString()} key-derivation rounds, which is too expensive to open.`;
+ case Pkcs12ErrorCode.NoEntries:
+ return "This keystore contains no certificates or private keys.";
+ case Pkcs12ErrorCode.NoPairs:
+ return `This keystore contains ${count ?? "one or more"} private key${count === 1 ? "" : "s"} with no matching certificate. Re-export it with each certificate and its private key together.`;
+ case Pkcs12ErrorCode.BadPassword:
+ default:
+ return "Could not decrypt the keystore. Check the password and try again.";
+ }
+};
+
+// The dialog's single entry point. Errors come back as a message rather than a throw, so the modal
+// never needs to import this module eagerly just to name the error class.
+export const readKeystore = async (
+ file: ArrayBuffer,
+ password: string
+): Promise<{ entries: TPkcs12Entry[]; error?: never } | { entries?: never; error: string }> => {
+ try {
+ return await extractPkcs12Entries({ pkcs12: new Uint8Array(file), password });
+ } catch (err) {
+ if (err instanceof Pkcs12ExtractionError)
+ return { error: pkcs12ErrorMessage(err.code, err.count) };
+ return { error: "Could not read this keystore." };
+ }
+};
diff --git a/frontend/src/hooks/api/auditLogs/constants.tsx b/frontend/src/hooks/api/auditLogs/constants.tsx
index 705546fe63..10c738f109 100644
--- a/frontend/src/hooks/api/auditLogs/constants.tsx
+++ b/frontend/src/hooks/api/auditLogs/constants.tsx
@@ -112,7 +112,6 @@ export const eventToNameMap: { [K in EventType]: string } = {
[EventType.GET_CERT_PRIVATE_KEY]: "Get certificate private key",
[EventType.GET_CERT_BUNDLE]: "Get certificate bundle",
[EventType.EXPORT_CERT_PKCS12]: "Export certificate as PKCS#12",
- [EventType.EXTRACT_CERT_PKCS12]: "Read PKCS#12 keystore",
[EventType.CREATE_PKI_ALERT]: "Create PKI alert",
[EventType.GET_PKI_ALERT]: "Get PKI alert",
[EventType.UPDATE_PKI_ALERT]: "Update PKI alert",
diff --git a/frontend/src/hooks/api/auditLogs/enums.tsx b/frontend/src/hooks/api/auditLogs/enums.tsx
index 4c804d6a99..09309d3c48 100644
--- a/frontend/src/hooks/api/auditLogs/enums.tsx
+++ b/frontend/src/hooks/api/auditLogs/enums.tsx
@@ -127,7 +127,6 @@ export enum EventType {
GET_CERT_PRIVATE_KEY = "get-cert-private-key",
GET_CERT_BUNDLE = "get-cert-bundle",
EXPORT_CERT_PKCS12 = "export-cert-pkcs12",
- EXTRACT_CERT_PKCS12 = "extract-cert-pkcs12",
CREATE_PKI_ALERT = "create-pki-alert",
GET_PKI_ALERT = "get-pki-alert",
UPDATE_PKI_ALERT = "update-pki-alert",
diff --git a/frontend/src/hooks/api/certificates/index.tsx b/frontend/src/hooks/api/certificates/index.tsx
index 4bd4aa5736..d1b495088a 100644
--- a/frontend/src/hooks/api/certificates/index.tsx
+++ b/frontend/src/hooks/api/certificates/index.tsx
@@ -5,7 +5,6 @@ export {
useCancelCertificateRequest,
useDeleteCert,
useDownloadCertPkcs12,
- useExtractPkcs12,
useImportCertificate,
useImportPkcs12Entries,
useRenewCertificate,
diff --git a/frontend/src/hooks/api/certificates/mutations.tsx b/frontend/src/hooks/api/certificates/mutations.tsx
index 214831d972..b923a14b3f 100644
--- a/frontend/src/hooks/api/certificates/mutations.tsx
+++ b/frontend/src/hooks/api/certificates/mutations.tsx
@@ -11,8 +11,6 @@ import {
TCertificate,
TDeleteCertDTO,
TDownloadPkcs12DTO,
- TExtractPkcs12DTO,
- TExtractPkcs12Response,
TImportCertificateDTO,
TImportCertificateResponse,
TImportPkcs12EntriesDTO,
@@ -113,18 +111,6 @@ export const useImportCertificate = () => {
});
};
-export const useExtractPkcs12 = () =>
- useMutation<TExtractPkcs12Response, object, TExtractPkcs12DTO>({
- meta: { handledErrorCodes: ["BadRequest"] },
- mutationFn: async (body) => {
- const { data } = await apiRequest.post<TExtractPkcs12Response>(
- "/api/v1/cert-manager/certificates/pkcs12/extract",
- body
- );
- return data;
- }
- });
-
// Failures are returned rather than thrown, so one bad entry neither aborts the rest nor raises a
// toast from the global error handler.
export const useImportPkcs12Entries = () => {
diff --git a/frontend/src/hooks/api/certificates/types.ts b/frontend/src/hooks/api/certificates/types.ts
index 3706b7badf..e4ea14d291 100644
--- a/frontend/src/hooks/api/certificates/types.ts
+++ b/frontend/src/hooks/api/certificates/types.ts
@@ -1,3 +1,5 @@
+import type { TPkcs12Entry } from "@app/helpers/pkcs12";
+
import {
CertExtendedKeyUsage,
CertificateRequestStatus,
@@ -80,30 +82,6 @@ export type TRevokeCertDTO = {
revocationReason: string;
};
-export type TExtractPkcs12DTO = {
- pkcs12: string;
- password: string;
- applicationId?: string;
-};
-
-export type TPkcs12Entry = {
- alias: string | null;
- subject: string;
- commonName: string | null;
- altNames: string | null;
- keyAlgorithm: string;
- notAfter: string;
- fingerprintSha256: string;
- chainWarning: string | null;
- certificatePem: string;
- chainPem?: string;
- privateKeyPem?: string;
-};
-
-export type TExtractPkcs12Response = {
- entries: TPkcs12Entry[];
-};
-
export type TImportPkcs12EntriesDTO = {
entries: TPkcs12Entry[];
applicationId?: string;
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateImportModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateImportModal.tsx
index 3f40510f42..2acde659c2 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateImportModal.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateImportModal.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useRef, useState } from "react";
+import { useEffect, useState } from "react";
import { Controller, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { CircleCheck, CircleX, TriangleAlert } from "lucide-react";
@@ -41,13 +41,8 @@ import {
TooltipContent,
TooltipTrigger
} from "@app/components/v3";
-import {
- useExtractPkcs12,
- useGetCert,
- useImportCertificate,
- useImportPkcs12Entries
-} from "@app/hooks/api";
-import { TPkcs12Entry } from "@app/hooks/api/certificates/types";
+import type { TPkcs12Entry } from "@app/helpers/pkcs12";
+import { useGetCert, useImportCertificate, useImportPkcs12Entries } from "@app/hooks/api";
import { UsePopUpState } from "@app/hooks/usePopUp";
import { CertificateContent } from "./CertificateContent";
@@ -83,16 +78,6 @@ type TImportOutcome = {
error?: string;
};
-// Spreading the whole buffer into String.fromCharCode overflows the stack near a megabyte.
-const toBase64 = (buffer: ArrayBuffer) => {
- const bytes = new Uint8Array(buffer);
- let binary = "";
- for (let i = 0; i < bytes.length; i += 8192) {
- binary += String.fromCharCode(...bytes.subarray(i, i + 8192));
- }
- return btoa(binary);
-};
-
const entryLabel = (entry: TPkcs12Entry) =>
entry.altNames || entry.commonName || entry.alias || entry.subject;
@@ -103,7 +88,7 @@ export const CertificateImportModal = ({ popUp, handlePopUpToggle, applicationId
);
const { mutateAsync: importCertificate } = useImportCertificate();
- const { mutateAsync: extractPkcs12, isPending: isExtracting } = useExtractPkcs12();
+ const [isExtracting, setIsExtracting] = useState(false);
const { mutateAsync: importEntries, isPending: isImportingEntries } = useImportPkcs12Entries();
const [keystoreFiles, setKeystoreFiles] = useState<File[]>([]);
@@ -169,26 +154,26 @@ export const CertificateImportModal = ({ popUp, handlePopUpToggle, applicationId
setKeystoreError(null);
if (file.size > MAX_KEYSTORE_BYTES) {
- setKeystoreError(
- "This file is larger than 1 MB, which is bigger than any keystore we expect."
- );
+ setKeystoreError("This file is larger than 1 MB. Upload a keystore under 1 MB.");
return;
}
+ setIsExtracting(true);
try {
- const result = await extractPkcs12({
- pkcs12: toBase64(await file.arrayBuffer()),
- password: keystorePassword,
- applicationId
- });
-
- setEntries(result.entries);
- setSelected(new Set(result.entries.map((entry) => entry.fingerprintSha256)));
- } catch (err) {
- setKeystoreError(
- (err as { response?: { data?: { message?: string } } })?.response?.data?.message ??
- "Could not read this keystore."
- );
+ // Loaded on demand so node-forge stays out of the main bundle.
+ const { readKeystore } = await import("@app/helpers/pkcs12");
+ const result = await readKeystore(await file.arrayBuffer(), keystorePassword);
+
+ if (!result.entries) {
+ setKeystoreError(result.error);
+ return;
+ }
+
+ const found = result.entries;
+ setEntries(found);
+ setSelected(new Set(found.map((entry) => entry.fingerprintSha256)));
+ } finally {
+ setIsExtracting(false);
}
};
@@ -223,12 +208,10 @@ export const CertificateImportModal = ({ popUp, handlePopUpToggle, applicationId
};
const isOpen = Boolean(popUp?.certificateImport?.isOpen);
- const wasOpen = useRef(isOpen);
useEffect(() => {
// Radix fires onOpenChange only for its own interactions, so our footer buttons never reach it.
- if (isOpen && !wasOpen.current) resetAll();
- wasOpen.current = isOpen;
- });
+ if (isOpen) resetAll();
+ }, [isOpen]);
const pemFieldsDisabled = Boolean(cert);
@@ -338,7 +321,7 @@ export const CertificateImportModal = ({ popUp, handlePopUpToggle, applicationId
<TableCell className="max-w-0">
<div className="truncate">{entryLabel(entry)}</div>
</TableCell>
- <TableCell>{(entry.privateKeyPem && entry.keyAlgorithm) || "—"}</TableCell>
+ <TableCell>{entry.keyAlgorithm || "—"}</TableCell>
<TableCell>
{entry.chainWarning ? (
<Tooltip>