Skip to content

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

fix(pki): remove stale-file cleanup, normalize ec keys for jks, hide unused export options

bernie-gfa41a01de948
diff --git a/backend/src/services/certificate-sync/certificate-sync-schemas.ts b/backend/src/services/certificate-sync/certificate-sync-schemas.ts
index b3f44f4de4..0676e2b381 100644
--- a/backend/src/services/certificate-sync/certificate-sync-schemas.ts
+++ b/backend/src/services/certificate-sync/certificate-sync-schemas.ts
@@ -19,9 +19,7 @@ export const BaseSyncMetadataSchema = z.object({}).catchall(z.unknown());
* removal targets exactly what was written
*/
export const ServerSyncMetadataSchema = z.object({
- files: z.array(z.string()).optional(),
- truststoreFiles: z.array(z.string()).optional(),
- host: z.string().optional()
+ files: z.array(z.string()).optional()
});
export const SyncMetadataSchema = AwsElbSyncMetadataSchema.extend(ServerSyncMetadataSchema.shape)
diff --git a/backend/src/services/certificate/certificate-jks-fns.test.ts b/backend/src/services/certificate/certificate-jks-fns.test.ts
index 6015107510..3406ec9064 100644
--- a/backend/src/services/certificate/certificate-jks-fns.test.ts
+++ b/backend/src/services/certificate/certificate-jks-fns.test.ts
@@ -126,6 +126,33 @@ const recoverPrivateKey = (encryptedPrivateKeyInfo: Buffer, password: string) =>
return plain;
};
+const P256_OID_TLV = Buffer.from("06082a8648ce3d030107", "hex");
+// Public P-256 domain parameters (ECParameters), as "openssl ecparam -param_enc explicit" writes them.
+const P256_EXPLICIT_PARAMETERS = Buffer.from(
+ "3081f7020101302c06072a8648ce3d0101022100ffffffff00000001000000000000000000000000ffffffffffffffffffffffff305b0420ffffffff00000001000000000000000000000000fffffffffffffffffffffffc04205ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b031500c49d360886e704936a6678e1139d26b7819f7e900441046b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c2964fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5022100ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551020101",
+ "hex"
+);
+
+const derLength = (length: number) =>
+ length < 0x80 ? Buffer.from([length]) : Buffer.from([0x82, (length >> 8) & 0xff, length & 0xff]);
+const derSequence = (...parts: Buffer[]) => {
+ const body = Buffer.concat(parts);
+ return Buffer.concat([Buffer.from([0x30]), derLength(body.length), body]);
+};
+
+// Swaps the named-curve OID in a P-256 PKCS#8 key for the explicit parameters it stands for.
+const toExplicitCurvePkcs8 = (namedPkcs8: Buffer) => {
+ const algorithm = Buffer.from("301306072a8648ce3d020106082a8648ce3d030107", "hex");
+ const start = namedPkcs8.indexOf(algorithm);
+ const version = Buffer.from("020100", "hex");
+ const privateKey = namedPkcs8.subarray(start + algorithm.length);
+ return derSequence(
+ version,
+ derSequence(Buffer.from("06072a8648ce3d0201", "hex"), P256_EXPLICIT_PARAMETERS),
+ privateKey
+ );
+};
+
const der = (pem: string) => new crypto.X509Certificate(pem).raw;
const privateKeyEntry = (jks: Buffer, password: string) => {
@@ -221,6 +248,49 @@ describe("generateJksFromCertificate", () => {
expectKeyMatchesCertificate(recoverPrivateKey(entry.protectedKey, PASSWORD), entry.chain[0]);
});
+ test("re-encodes an EC key with explicit curve parameters using the named curve", async () => {
+ const keys = (await webcrypto.subtle.generateKey({ name: "ECDSA", namedCurve: "P-256" }, true, [
+ "sign",
+ "verify"
+ ])) as CryptoKeyPair;
+ const cert = await x509.X509CertificateGenerator.createSelfSigned({
+ serialNumber: "03",
+ name: "CN=explicit.example.com",
+ notBefore: new Date(2026, 0, 1),
+ notAfter: new Date(2027, 0, 1),
+ signingAlgorithm: { name: "ECDSA", hash: "SHA-256" },
+ keys
+ });
+ const namedPkcs8 = Buffer.from(await webcrypto.subtle.exportKey("pkcs8", keys.privateKey));
+ const explicitPkcs8 = toExplicitCurvePkcs8(namedPkcs8);
+ const explicitKey = crypto.createPrivateKey({ key: explicitPkcs8, format: "der", type: "pkcs8" });
+ expect(explicitKey.export({ type: "pkcs8", format: "der" }).includes(P256_OID_TLV)).toBe(false);
+
+ const jks = generateJksFromCertificate({
+ certificate: cert.toString("pem"),
+ privateKey: explicitKey.export({ type: "pkcs8", format: "pem" }) as string,
+ password: PASSWORD,
+ alias: "explicit"
+ });
+
+ const entry = privateKeyEntry(jks, PASSWORD);
+ const recovered = recoverPrivateKey(entry.protectedKey, PASSWORD);
+ expect(recovered.includes(P256_OID_TLV)).toBe(true);
+ expectKeyMatchesCertificate(recovered, entry.chain[0]);
+ });
+
+ test("rejects EC keys on curves Java does not support", () => {
+ const { privateKey } = crypto.generateKeyPairSync("ec", { namedCurve: "secp224r1" });
+ expect(() =>
+ generateJksFromCertificate({
+ certificate: leaf.certificate,
+ privateKey: privateKey.export({ type: "pkcs8", format: "pem" }) as string,
+ password: PASSWORD,
+ alias: "a"
+ })
+ ).toThrow("P-256, P-384, and P-521 curves only");
+ });
+
test("rejects a private key that does not belong to the certificate", () => {
expect(() =>
generateJksFromCertificate({
diff --git a/backend/src/services/certificate/certificate-jks-fns.ts b/backend/src/services/certificate/certificate-jks-fns.ts
index 8df79b52a0..e8708ba29e 100644
--- a/backend/src/services/certificate/certificate-jks-fns.ts
+++ b/backend/src/services/certificate/certificate-jks-fns.ts
@@ -1,4 +1,6 @@
/* eslint-disable no-bitwise */
+import type { JsonWebKey, KeyObject } from "node:crypto";
+
import { crypto } from "@app/lib/crypto/cryptography";
import { BadRequestError } from "@app/lib/errors";
@@ -96,6 +98,24 @@ const certificateDer = (pem: string): Buffer => {
};
const JKS_SUPPORTED_KEY_TYPES = new Set(["rsa", "ec"]);
+const JKS_SUPPORTED_EC_CURVES = new Set(["P-256", "P-384", "P-521"]);
+
+// Java cannot load an EC key encoded with explicit curve parameters, so re-encode it with the named curve.
+const toNamedCurveEcKey = (key: KeyObject): KeyObject => {
+ let jwk: JsonWebKey | undefined;
+ try {
+ jwk = key.export({ format: "jwk" });
+ } catch {
+ jwk = undefined;
+ }
+ if (!jwk?.crv || !JKS_SUPPORTED_EC_CURVES.has(jwk.crv)) {
+ throw new BadRequestError({
+ message:
+ "Java KeyStore export supports EC keys on the P-256, P-384, and P-521 curves only. Use PEM format instead."
+ });
+ }
+ return crypto.nativeCrypto.createPrivateKey({ key: jwk, format: "jwk" });
+};
const privateKeyPkcs8Der = (privateKeyPem: string, leafCertificatePem: string): Buffer => {
let key;
@@ -112,6 +132,8 @@ const privateKeyPkcs8Der = (privateKeyPem: string, leafCertificatePem: string):
});
}
+ if (key.asymmetricKeyType === "ec") key = toNamedCurveEcKey(key);
+
if (!new crypto.nativeCrypto.X509Certificate(leafCertificatePem).checkPrivateKey(key)) {
throw new BadRequestError({
message: "The certificate's private key does not match its public key, so it cannot be exported"
diff --git a/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-fns.ts b/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-fns.ts
index 58dafa5fda..4827ea485b 100644
--- a/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-fns.ts
+++ b/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-fns.ts
@@ -28,15 +28,12 @@ import { TSyncMetadata } from "@app/services/certificate-sync/certificate-sync-s
import { PkiSyncError } from "../pki-sync-errors";
import {
buildFileCollisionMessage,
- buildStaleFileWarning,
exportCertificateForSync,
isExportFormatBlockedByFips,
isKeystoreExportFormat,
JKS_FIPS_UNSUPPORTED_MESSAGE,
- JKS_TRUSTSTORE_SUFFIX,
PemCertificateExtension,
- PkiSyncExportFormat,
- planStaleCertificateFileCleanup
+ PkiSyncExportFormat
} from "../pki-sync-export-fns";
import {
buildHealthCheckCommandFailureMessage,
@@ -244,20 +241,6 @@ const unlinkIfExists = (sftp: SFTPWrapper, filePath: string): Promise<void> =>
sftp.unlink(filePath, () => resolve());
});
-// SFTP status code for a missing file. ssh2 is CommonJS, so its "utils" export can't be imported by name.
-const SFTP_STATUS_NO_SUCH_FILE = 2;
-
-const unlinkOrThrow = (sftp: SFTPWrapper, filePath: string): Promise<void> =>
- new Promise<void>((resolve, reject) => {
- sftp.unlink(filePath, (err) => {
- if (!err || (err as { code?: number }).code === SFTP_STATUS_NO_SUCH_FILE) {
- resolve();
- return;
- }
- reject(err);
- });
- });
-
const TEMP_FILE_MARKER = ".infisical.tmp";
// A write completes in seconds, so any temp file older than this was left by an interrupted run
// (dropped connection between write and rename) and is safe to remove even if another sync shares
@@ -458,7 +441,6 @@ export const linuxServerPkiSyncFactory = ({
const failedUploads: Array<{ name: string; error: string }> = [];
const failedRemovals: Array<{ name: string; error: string }> = [];
- const staleFileFailures: Array<{ path: string; error: string }> = [];
const skippedCertificates: Array<{ name: string; reason: string }> = [];
// Paths confirmed on the host this run. Keeps the removal pass from deleting a file a renewal
// just rewrote under the same name, and tells the post-sync command what landed.
@@ -469,11 +451,10 @@ export const linuxServerPkiSyncFactory = ({
const sshConfig = await buildSshConfig(pkiSync, { gatewayV2Service, gatewayPoolService, keyStore });
const gatewayLabel = await resolveGatewayLabel(gatewayV2Service, sshConfig.gatewayId);
- const targetHost = sshConfig.credentials.host;
const describeFailure = (error: unknown) =>
describeHostFailure({
error,
- host: targetHost,
+ host: (pkiSync.destinationConfig as TLinuxServerPkiSyncConfig).host,
gatewayLabel,
transport: "SSH"
});
@@ -540,7 +521,6 @@ export const linuxServerPkiSyncFactory = ({
}
const writtenPaths: string[] = [];
- const writtenTruststorePaths: string[] = [];
for (const file of files) {
const filePath = path.posix.join(config.destinationPath, `${baseName}${file.suffix}`);
try {
@@ -561,7 +541,6 @@ export const linuxServerPkiSyncFactory = ({
}
await applyOwnership(client, options.owner, options.group, filePath);
writtenPaths.push(filePath);
- if (file.suffix === JKS_TRUSTSTORE_SUFFIX) writtenTruststorePaths.push(filePath);
deliveredPaths.add(filePath);
}
@@ -575,33 +554,9 @@ export const linuxServerPkiSyncFactory = ({
]);
}
if (record) {
- const { filesToRemove, buildSyncMetadata } = planStaleCertificateFileCleanup({
- previousMetadata: record.syncMetadata as TSyncMetadata,
- previousExternalIdentifier: record.externalIdentifier,
- writtenPaths,
- writtenTruststorePaths,
- deliveredPaths,
- currentHost: targetHost,
- canRemoveCertificates
- });
- const staleFilesToRetry: string[] = [];
- for (const staleFile of filesToRemove) {
- try {
- await unlinkOrThrow(sftp, staleFile);
- } catch (removeErr) {
- staleFilesToRetry.push(staleFile);
- staleFileFailures.push({ path: staleFile, error: describeFailure(removeErr) });
- }
- }
- const removedCount = filesToRemove.length - staleFilesToRetry.length;
- if (removedCount > 0) {
- logger.info(
- `Linux Server PKI sync [syncId=${pkiSync.id}]: removed ${removedCount} file(s) "${baseName}" no longer uses`
- );
- }
await certificateSyncDAL.updateById(record.id, {
externalIdentifier: primaryPath,
- syncMetadata: buildSyncMetadata(staleFilesToRetry)
+ syncMetadata: { files: writtenPaths }
});
}
}
@@ -660,7 +615,6 @@ export const linuxServerPkiSyncFactory = ({
skipped: skippedCertificates.length,
healthCheck,
postSyncCommand,
- warningMessage: buildStaleFileWarning(staleFileFailures),
details: {
failedUploads: failedUploads.length > 0 ? failedUploads : undefined,
failedRemovals: failedRemovals.length > 0 ? failedRemovals : undefined,
diff --git a/backend/src/services/pki-sync/pki-sync-export-fns.test.ts b/backend/src/services/pki-sync/pki-sync-export-fns.test.ts
index 0f3ab4fdc1..a5dd138ab5 100644
--- a/backend/src/services/pki-sync/pki-sync-export-fns.test.ts
+++ b/backend/src/services/pki-sync/pki-sync-export-fns.test.ts
@@ -3,14 +3,12 @@ import forge from "node-forge";
import { crypto } from "@app/lib/crypto/cryptography";
import {
- buildStaleFileWarning,
exportCertificateForSync,
getExportedCertificateFileSuffixes,
getUnusedKeystoreOptionMessage,
isExportFormatBlockedByFips,
PemCertificateExtension,
PkiSyncExportFormat,
- planStaleCertificateFileCleanup,
TExportedCertificateFile
} from "./pki-sync-export-fns";
@@ -256,118 +254,3 @@ describe("isExportFormatBlockedByFips", () => {
expect(isExportFormatBlockedByFips(PkiSyncExportFormat.Jks)).toBe(false);
});
});
-
-describe("planStaleCertificateFileCleanup", () => {
- const host = "host-a";
- const base = {
- writtenPaths: ["/certs/app.jks"],
- writtenTruststorePaths: [],
- deliveredPaths: new Set(["/certs/app.jks"]),
- currentHost: host
- };
- const previousMetadata = {
- host,
- files: ["/certs/app.pem", "/certs/app.key", "/certs/app.truststore.jks"],
- truststoreFiles: ["/certs/app.truststore.jks"]
- };
-
- test("removes every stale file when certificate removal is on", () => {
- const plan = planStaleCertificateFileCleanup({ ...base, previousMetadata, canRemoveCertificates: true });
- expect(plan.filesToRemove).toEqual(previousMetadata.files);
- expect(plan.buildSyncMetadata([])).toEqual({ files: ["/certs/app.jks"], truststoreFiles: [], host });
- });
-
- test("only removes a recorded truststore when certificate removal is off, and keeps tracking the rest", () => {
- const plan = planStaleCertificateFileCleanup({ ...base, previousMetadata, canRemoveCertificates: false });
- expect(plan.filesToRemove).toEqual(["/certs/app.truststore.jks"]);
- expect(plan.buildSyncMetadata([]).files).toEqual(["/certs/app.jks", "/certs/app.pem", "/certs/app.key"]);
- });
-
- test("keeps tracking a file whose removal failed so the next sync retries it", () => {
- const plan = planStaleCertificateFileCleanup({ ...base, previousMetadata, canRemoveCertificates: false });
- expect(plan.buildSyncMetadata(["/certs/app.truststore.jks"])).toEqual({
- files: ["/certs/app.jks", "/certs/app.pem", "/certs/app.key", "/certs/app.truststore.jks"],
- truststoreFiles: ["/certs/app.truststore.jks"],
- host
- });
- });
-
- test("keeps a keystore whose certificate name ends in .truststore", () => {
- const plan = planStaleCertificateFileCleanup({
- ...base,
- previousMetadata: { host, files: ["/certs/api.truststore.jks"], truststoreFiles: [] },
- canRemoveCertificates: false
- });
- expect(plan.filesToRemove).toEqual([]);
- expect(plan.buildSyncMetadata([]).files).toContain("/certs/api.truststore.jks");
- });
-
- test("keeps a file another certificate wrote this run", () => {
- const plan = planStaleCertificateFileCleanup({
- ...base,
- deliveredPaths: new Set(["/certs/app.jks", "/certs/app.pem"]),
- previousMetadata,
- canRemoveCertificates: true
- });
- expect(plan.filesToRemove).toEqual(["/certs/app.key", "/certs/app.truststore.jks"]);
- });
-
- test("deletes nothing and keeps tracking files recorded before hosts were saved", () => {
- const plan = planStaleCertificateFileCleanup({
- ...base,
- previousMetadata: { files: ["/certs/app.pem", "/certs/app.key"] },
- canRemoveCertificates: true
- });
- expect(plan.filesToRemove).toEqual([]);
- expect(plan.buildSyncMetadata([])).toEqual({
- files: ["/certs/app.jks", "/certs/app.pem", "/certs/app.key"],
- truststoreFiles: [],
- host
- });
- });
-
- test("neither deletes nor keeps files recorded on a different host", () => {
- const plan = planStaleCertificateFileCleanup({
- ...base,
- previousMetadata: { ...previousMetadata, host: "host-b" },
- canRemoveCertificates: true
- });
- expect(plan.filesToRemove).toEqual([]);
- expect(plan.buildSyncMetadata([]).files).toEqual(["/certs/app.jks"]);
- });
-
- test("falls back to the external identifier when no files were recorded", () => {
- const plan = planStaleCertificateFileCleanup({
- ...base,
- previousMetadata: { host, files: [] },
- previousExternalIdentifier: "/certs/app.pfx",
- canRemoveCertificates: true
- });
- expect(plan.filesToRemove).toEqual(["/certs/app.pfx"]);
- });
-
- test("compares paths without regard to case when asked", () => {
- const plan = planStaleCertificateFileCleanup({
- writtenPaths: ["C:\\certs\\App.jks"],
- writtenTruststorePaths: [],
- deliveredPaths: new Set(["C:\\certs\\App.jks"]),
- currentHost: "HOST-A",
- previousMetadata: { host, files: ["C:\\certs\\app.jks", "C:\\certs\\app.pem"] },
- canRemoveCertificates: true,
- caseInsensitive: true
- });
- expect(plan.filesToRemove).toEqual(["C:\\certs\\app.pem"]);
- });
-});
-
-describe("buildStaleFileWarning", () => {
- test("returns nothing when every removal succeeded", () => {
- expect(buildStaleFileWarning([])).toBeUndefined();
- });
-
- test("names the files that could not be removed", () => {
- const warning = buildStaleFileWarning([{ path: "/certs/app.truststore.jks", error: "Permission denied" }]);
- expect(warning).toContain("/certs/app.truststore.jks");
- expect(warning).toContain("Permission denied");
- });
-});
diff --git a/backend/src/services/pki-sync/pki-sync-export-fns.ts b/backend/src/services/pki-sync/pki-sync-export-fns.ts
index 274eea236c..116cbc7618 100644
--- a/backend/src/services/pki-sync/pki-sync-export-fns.ts
+++ b/backend/src/services/pki-sync/pki-sync-export-fns.ts
@@ -5,7 +5,6 @@ import {
generateJksTruststore,
getJksTruststoreCertificates
} from "@app/services/certificate/certificate-jks-fns";
-import { TSyncMetadata } from "@app/services/certificate-sync/certificate-sync-schemas";
export enum PkiSyncExportFormat {
Pem = "pem",
@@ -44,71 +43,6 @@ export const KEYSTORE_PASSWORD_REQUIRED_MESSAGE = "A password is required when t
export const JKS_KEYSTORE_SUFFIX = ".jks";
export const JKS_TRUSTSTORE_SUFFIX = ".truststore.jks";
-// A stale truststore still grants trust, so it is removed even when certificate removal is off.
-export const planStaleCertificateFileCleanup = ({
- previousMetadata,
- previousExternalIdentifier,
- writtenPaths,
- writtenTruststorePaths,
- deliveredPaths,
- currentHost,
- canRemoveCertificates,
- caseInsensitive = false
-}: {
- previousMetadata: TSyncMetadata;
- previousExternalIdentifier?: string | null;
- writtenPaths: string[];
- writtenTruststorePaths: string[];
- deliveredPaths: Set<string>;
- currentHost: string;
- canRemoveCertificates: boolean;
- caseInsensitive?: boolean;
-}) => {
- const normalize = (filePath: string) => (caseInsensitive ? filePath.toLowerCase() : filePath);
- const previousFiles = previousMetadata?.files?.length
- ? previousMetadata.files
- : [previousExternalIdentifier].filter((filePath): filePath is string => Boolean(filePath));
- const current = new Set([...writtenPaths, ...deliveredPaths].map(normalize));
- const staleFiles = previousFiles.filter((filePath) => !current.has(normalize(filePath)));
-
- const truststores = new Set((previousMetadata?.truststoreFiles ?? []).map((filePath) => filePath.toLowerCase()));
- const isTruststore = (filePath: string) => truststores.has(filePath.toLowerCase());
-
- const previousHost = previousMetadata?.host;
- let filesToRemove: string[] = [];
- let filesToKeep: string[] = [];
- if (!previousHost) {
- // Recorded before hosts were saved, so keep tracking the files without deleting anything yet.
- filesToKeep = staleFiles;
- } else if (previousHost.toLowerCase() === currentHost.toLowerCase()) {
- filesToRemove = canRemoveCertificates ? staleFiles : staleFiles.filter(isTruststore);
- filesToKeep = canRemoveCertificates ? [] : staleFiles.filter((filePath) => !isTruststore(filePath));
- }
-
- const buildSyncMetadata = (filesToRetry: string[]) => {
- const trackedStaleFiles = [...filesToKeep, ...filesToRetry];
- return {
- files: [...writtenPaths, ...trackedStaleFiles],
- truststoreFiles: [...writtenTruststorePaths, ...trackedStaleFiles.filter(isTruststore)],
- host: currentHost
- };
- };
-
- return { filesToRemove, buildSyncMetadata };
-};
-
-const MAX_LISTED_STALE_FILES = 3;
-
-export const buildStaleFileWarning = (failures: Array<{ path: string; error: string }>): string | undefined => {
- if (failures.length === 0) return undefined;
- const listed = failures
- .slice(0, MAX_LISTED_STALE_FILES)
- .map(({ path, error }) => `"${path}" (${error})`)
- .join(", ");
- const more = failures.length > MAX_LISTED_STALE_FILES ? ` and ${failures.length - MAX_LISTED_STALE_FILES} more` : "";
- return `Could not remove ${failures.length} file(s) this sync no longer writes: ${listed}${more}. Removal will be retried on the next sync.`;
-};
-
export enum PemCertificateExtension {
Pem = "pem",
Crt = "crt"
diff --git a/backend/src/services/pki-sync/pki-sync-queue.ts b/backend/src/services/pki-sync/pki-sync-queue.ts
index af3d08e18f..37faa443ef 100644
--- a/backend/src/services/pki-sync/pki-sync-queue.ts
+++ b/backend/src/services/pki-sync/pki-sync-queue.ts
@@ -420,7 +420,6 @@ export const pkiSyncQueueFactory = ({
? `${certSyncFailureCount} certificate(s) failed to sync to the destination`
: null,
syncResult.partialFailureMessage ?? null,
- syncResult.warningMessage ?? null,
postSyncCommandResult?.status === PkiSyncStatus.Failed
? buildPostSyncCommandFailureMessage(postSyncCommandResult)
: null
diff --git a/backend/src/services/pki-sync/pki-sync-types.ts b/backend/src/services/pki-sync/pki-sync-types.ts
index 707f2d40dc..97766a8bbc 100644
--- a/backend/src/services/pki-sync/pki-sync-types.ts
+++ b/backend/src/services/pki-sync/pki-sync-types.ts
@@ -151,7 +151,6 @@ export type TPkiSyncSyncResult = {
validationErrors?: Array<{ name: string; error: string }>;
};
partialFailureMessage?: string;
- warningMessage?: string;
};
export type TCreatePkiSyncDTO = {
diff --git a/backend/src/services/pki-sync/windows-server/windows-server-pki-sync-fns.ts b/backend/src/services/pki-sync/windows-server/windows-server-pki-sync-fns.ts
index c37eda9da9..ab3cf29d9b 100644
--- a/backend/src/services/pki-sync/windows-server/windows-server-pki-sync-fns.ts
+++ b/backend/src/services/pki-sync/windows-server/windows-server-pki-sync-fns.ts
@@ -19,15 +19,12 @@ import { TSyncMetadata } from "@app/services/certificate-sync/certificate-sync-s
import { PkiSyncError } from "../pki-sync-errors";
import {
buildFileCollisionMessage,
- buildStaleFileWarning,
exportCertificateForSync,
isExportFormatBlockedByFips,
isKeystoreExportFormat,
JKS_FIPS_UNSUPPORTED_MESSAGE,
- JKS_TRUSTSTORE_SUFFIX,
PemCertificateExtension,
- PkiSyncExportFormat,
- planStaleCertificateFileCleanup
+ PkiSyncExportFormat
} from "../pki-sync-export-fns";
import {
buildHealthCheckCommandFailureMessage,
@@ -333,7 +330,6 @@ export const windowsServerPkiSyncFactory = ({
const failedUploads: Array<{ name: string; error: string }> = [];
const failedRemovals: Array<{ name: string; error: string }> = [];
- const staleFileFailures: Array<{ path: string; error: string }> = [];
const skippedCertificates: Array<{ name: string; reason: string }> = [];
// Paths confirmed on the host this run. Keeps the removal pass from deleting a file a renewal
// just rewrote under the same name, and tells the post-sync command what landed.
@@ -394,13 +390,11 @@ export const windowsServerPkiSyncFactory = ({
});
const paths: string[] = [];
- const truststorePaths: string[] = [];
const files: Array<{ path: string; contentBase64: string }> = [];
for (const file of exported) {
const fullPath = joinWindowsPath(config.destinationPath, `${baseName}${file.suffix}`);
files.push({ path: fullPath, contentBase64: file.content.toString("base64") });
paths.push(fullPath);
- if (file.suffix === JKS_TRUSTSTORE_SUFFIX) truststorePaths.push(fullPath);
}
// Windows paths are case-insensitive, so compare them folded.
@@ -429,33 +423,9 @@ export const windowsServerPkiSyncFactory = ({
]);
}
if (record) {
- const { filesToRemove, buildSyncMetadata } = planStaleCertificateFileCleanup({
- previousMetadata: record.syncMetadata as TSyncMetadata,
- previousExternalIdentifier: record.externalIdentifier,
- writtenPaths: paths,
- writtenTruststorePaths: truststorePaths,
- deliveredPaths,
- currentHost: target.credentials.host,
- canRemoveCertificates,
- caseInsensitive: true
- });
- let staleFilesToRetry: string[] = [];
- if (filesToRemove.length > 0) {
- try {
- await executeWinRMGatewayOperation(
- { ...target, endpoint: WinRmRpcEndpoint.RemoveFiles, params: { paths: filesToRemove } },
- gatewayDeps
- );
- } catch (removeErr) {
- // Keep tracking them so a later run can retry the delete.
- staleFilesToRetry = filesToRemove;
- const error = describeFailure(removeErr);
- filesToRemove.forEach((staleFile) => staleFileFailures.push({ path: staleFile, error }));
- }
- }
await certificateSyncDAL.updateById(record.id, {
externalIdentifier: paths[0],
- syncMetadata: buildSyncMetadata(staleFilesToRetry)
+ syncMetadata: { files: paths }
});
}
}
@@ -507,7 +477,6 @@ export const windowsServerPkiSyncFactory = ({
skipped: skippedCertificates.length,
healthCheck,
postSyncCommand,
- warningMessage: buildStaleFileWarning(staleFileFailures),
details: {
failedUploads: failedUploads.length > 0 ? failedUploads : undefined,
failedRemovals: failedRemovals.length > 0 ? failedRemovals : undefined,
diff --git a/docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdx b/docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdx
index 7434b309e4..9765d1c262 100644
--- a/docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdx
+++ b/docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdx
@@ -152,8 +152,6 @@ Infisical writes a new keystore on every sync instead of adding to the file on t
Java KeyStore stores aliases in lowercase, so an alias of `Tomcat` is saved as `tomcat`. Java looks up aliases without regard to case, so configuring `Tomcat` in your server still finds the entry.
</Note>
-When you change the export format or turn off **Include Truststore**, the next sync removes a truststore it no longer writes. Other files it no longer writes, such as the `.pem` and `.key` files after a switch to Java KeyStore, are removed only when **Enable Removal of Certificates** is on. If a file can't be removed, the sync still succeeds, shows a warning, and tries again on the next sync.
-
<Warning>
Java KeyStore isn't available when Infisical runs in FIPS mode, because the format can only protect private keys with cryptography that isn't FIPS-approved. Use PEM instead.
</Warning>
diff --git a/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx b/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx
index 788f45be12..22178681bb 100644
--- a/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx
+++ b/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx
@@ -161,8 +161,6 @@ Infisical writes a new keystore on every sync instead of adding to the file on t
Java KeyStore stores aliases in lowercase, so an alias of `Tomcat` is saved as `tomcat`. Java looks up aliases without regard to case, so configuring `Tomcat` in your server still finds the entry.
</Note>
-When you change the export format or turn off **Include Truststore**, the next sync removes a truststore it no longer writes. Other files it no longer writes, such as the `.pem` and `.key` files after a switch to Java KeyStore, are removed only when **Enable Removal of Certificates** is on. If a file can't be removed, the sync still succeeds, shows a warning, and tries again on the next sync.
-
<Warning>
Java KeyStore isn't available when Infisical runs in FIPS mode, because the format can only protect private keys with cryptography that isn't FIPS-approved. Use PEM instead.
</Warning>
diff --git a/frontend/src/components/pki-syncs/PkiSyncStatusBadge.tsx b/frontend/src/components/pki-syncs/PkiSyncStatusBadge.tsx
index e2f050c89d..f019038e4b 100644
--- a/frontend/src/components/pki-syncs/PkiSyncStatusBadge.tsx
+++ b/frontend/src/components/pki-syncs/PkiSyncStatusBadge.tsx
@@ -16,7 +16,7 @@ import {
HoverCardTrigger,
TBadgeProps
} from "@app/components/v3";
-import { getPkiSyncFailureMessage, getPkiSyncWarningMessage } from "@app/helpers/pkiSyncs";
+import { getPkiSyncFailureMessage } from "@app/helpers/pkiSyncs";
import { PkiSyncStatus } from "@app/hooks/api/pkiSyncs";
type Props = {
@@ -55,7 +55,6 @@ export const PkiSyncStatusBadge = ({ status, lastSyncedAt, lastSyncMessage }: Pr
}
const failureMessage = getPkiSyncFailureMessage(status, lastSyncMessage);
- const warningMessage = getPkiSyncWarningMessage(status, lastSyncMessage);
const badge = (
<Badge variant={variant}>
@@ -66,7 +65,7 @@ export const PkiSyncStatusBadge = ({ status, lastSyncedAt, lastSyncMessage }: Pr
if (
![PkiSyncStatus.Succeeded, PkiSyncStatus.Failed].includes(status) ||
- (!lastSyncedAt && !failureMessage && !warningMessage)
+ (!lastSyncedAt && !failureMessage)
) {
return badge;
}
@@ -89,17 +88,6 @@ export const PkiSyncStatusBadge = ({ status, lastSyncedAt, lastSyncMessage }: Pr
</div>
</div>
)}
- {warningMessage && (
- <div>
- <div className="mb-2 flex items-center gap-1.5 self-start text-warning">
- <AlertTriangleIcon className="size-3" />
- <div className="text-xs">Warning</div>
- </div>
- <div className="rounded-sm bg-surface-active p-2 text-xs break-words">
- {warningMessage}
- </div>
- </div>
- )}
{failureMessage && (
<div>
<div className="mb-2 flex items-center gap-1.5 self-start text-danger">
diff --git a/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx b/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx
index 96ea6e90fd..11410e29f6 100644
--- a/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx
+++ b/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx
@@ -1,5 +1,5 @@
import { useState } from "react";
-import { Controller, FieldPath, FormProvider, useForm } from "react-hook-form";
+import { Controller, FieldErrors, FieldPath, FormProvider, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { AlertTriangleIcon } from "lucide-react";
@@ -33,7 +33,6 @@ import {
} from "@app/helpers/pkiSyncs";
import { AppConnection } from "@app/hooks/api/appConnections/enums";
import {
- isKeystoreExportFormat,
PkiSync,
PkiSyncExportFormat,
TPkiSync,
@@ -43,9 +42,9 @@ import {
usePkiSyncOption
} from "@app/hooks/api/pkiSyncs";
-import { KEYSTORE_PASSWORD_REQUIRED_MESSAGE } from "./schemas/base-pki-sync-schema";
import { KEMP_DEFAULT_CA_NAME_SCHEMA } from "./schemas/kemp-loadmaster-pki-sync-destination-schema";
import {
+ getKeystoreFieldIssues,
PkiSyncFormSchema,
removeUnusedKeystoreOptions,
TPkiSyncForm
@@ -303,28 +302,26 @@ export const CreatePkiSyncForm = ({
}
if (FORM_TABS[index].key === "options") {
- const values = getValues() as {
- destination?: PkiSync;
- syncOptions?: { exportFormat?: PkiSyncExportFormat };
- credentials?: { exportPassword?: string };
- };
- const requiresPassword =
- (values.destination === PkiSync.WindowsServer ||
- values.destination === PkiSync.LinuxServer) &&
- isKeystoreExportFormat(values.syncOptions?.exportFormat) &&
- !values.credentials?.exportPassword;
- if (requiresPassword) {
- setError("credentials.exportPassword" as FieldPath<TPkiSyncForm>, {
- type: "manual",
- message: KEYSTORE_PASSWORD_REQUIRED_MESSAGE
- });
- return false;
- }
+ const issues = getKeystoreFieldIssues(getValues(), { requirePassword: true });
+ issues.forEach(({ path, message }) =>
+ setError(path.join(".") as FieldPath<TPkiSyncForm>, { type: "manual", message })
+ );
+ if (issues.length > 0) return false;
}
return true;
};
+ // A field from an earlier step can fail only when the whole form is checked, so show that step.
+ const onInvalid = (errors: FieldErrors<TPkiSyncForm>) => {
+ const errorKeys = Object.keys(errors);
+ const stepIndex = FORM_TABS.findIndex((tab) =>
+ tab.fields.some((field) => errorKeys.includes(String(field).split(".")[0]))
+ );
+ setShowConfirmation(false);
+ if (stepIndex >= 0) setSelectedTabIndex(stepIndex);
+ };
+
const isFinalStep = selectedTabIndex === FORM_TABS.length - 1;
const handleNext = async () => {
@@ -517,7 +514,7 @@ export const CreatePkiSyncForm = ({
<AlertDialogAction
variant="project"
isDisabled={createPkiSync.isPending}
- onClick={handleSubmit(onSubmit)}
+ onClick={handleSubmit(onSubmit, onInvalid)}
>
I Understand
</AlertDialogAction>
diff --git a/frontend/src/components/pki-syncs/forms/PkiSyncReviewFields.tsx b/frontend/src/components/pki-syncs/forms/PkiSyncReviewFields.tsx
index cdf9cb318b..345d3269a2 100644
--- a/frontend/src/components/pki-syncs/forms/PkiSyncReviewFields.tsx
+++ b/frontend/src/components/pki-syncs/forms/PkiSyncReviewFields.tsx
@@ -14,13 +14,13 @@ import {
import { useProject } from "@app/context";
import {
BOOLEAN_SYNC_OPTION_FIELDS,
+ getUnusedExportOptionKeys,
KEY_VALUE_SYNC_OPTION_FIELDS,
PKI_SYNC_MAP,
VALUE_SYNC_OPTION_FIELDS
} from "@app/helpers/pkiSyncs";
import { useListCertificateProfiles } from "@app/hooks/api/certificateProfiles";
import {
- isKeystoreExportFormat,
PKI_SYNC_EXPORT_FORMAT_LABELS,
PkiSyncExportFormat,
usePkiSyncOption,
@@ -107,10 +107,7 @@ export const PkiSyncReviewFields = ({ applicationId }: Props = {}) => {
syncOptions && "postSyncCommand" in syncOptions ? syncOptions.postSyncCommand : undefined;
const exportFormat = (syncOptions as { exportFormat?: PkiSyncExportFormat } | undefined)
?.exportFormat;
- const inapplicableOptionKeys = new Set<string>([
- ...(isKeystoreExportFormat(exportFormat) ? [] : ["keystoreAlias"]),
- ...(exportFormat === PkiSyncExportFormat.Jks ? [] : ["includeTruststore"])
- ]);
+ const inapplicableOptionKeys = getUnusedExportOptionKeys(exportFormat);
const healthCheckCommand =
syncOptions && "healthCheckCommand" in syncOptions ? syncOptions.healthCheckCommand : undefined;
diff --git a/frontend/src/components/pki-syncs/forms/schemas/pki-sync-schema.ts b/frontend/src/components/pki-syncs/forms/schemas/pki-sync-schema.ts
index 2558cf20c5..52c1fe9345 100644
--- a/frontend/src/components/pki-syncs/forms/schemas/pki-sync-schema.ts
+++ b/frontend/src/components/pki-syncs/forms/schemas/pki-sync-schema.ts
@@ -123,54 +123,61 @@ const refineTargetHost = (data: unknown, ctx: z.RefinementCtx) => {
const isServerDestination = (destination: PkiSync) =>
destination === PkiSync.WindowsServer || destination === PkiSync.LinuxServer;
-const isServerSyncForm = <T extends { destination: PkiSync }>(
- data: T
-): data is Extract<T, { destination: PkiSync.WindowsServer | PkiSync.LinuxServer }> =>
- isServerDestination(data.destination);
-
-// Only keystore formats use the password, so a value left behind after switching to PEM is ignored.
-const refineExportPassword = (
- data: { destination: PkiSync; syncOptions?: unknown; credentials?: unknown },
- ctx: z.RefinementCtx
-) => {
- const password = (data.credentials as { exportPassword?: string } | undefined)?.exportPassword;
- const exportFormat = (data.syncOptions as { exportFormat?: PkiSyncExportFormat } | undefined)
- ?.exportFormat;
- if (!isServerDestination(data.destination) || !password || !isKeystoreExportFormat(exportFormat))
- return;
- const result = ExportPasswordSchema.safeParse(password);
- if (!result.success) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- path: ["credentials", "exportPassword"],
- message: result.error.issues[0]?.message ?? "Invalid export password"
- });
- }
+type TKeystoreFieldIssue = {
+ path: ["credentials", "exportPassword"] | ["syncOptions", "keystoreAlias"];
+ message: string;
};
-// The alias is kept while switching formats, so it is only validated when a keystore format uses it.
-const refineKeystoreAlias = (
- data: { destination: PkiSync; syncOptions?: unknown },
- ctx: z.RefinementCtx
-) => {
+// Values left behind after switching to PEM are not checked, since only keystore formats use them.
+export const getKeystoreFieldIssues = (
+ data: { destination?: PkiSync; syncOptions?: unknown; credentials?: unknown },
+ { requirePassword }: { requirePassword: boolean }
+): TKeystoreFieldIssue[] => {
const { exportFormat, keystoreAlias } = (data.syncOptions ?? {}) as {
exportFormat?: PkiSyncExportFormat;
keystoreAlias?: string;
};
- if (
- !isServerDestination(data.destination) ||
- !keystoreAlias ||
- !isKeystoreExportFormat(exportFormat)
- )
- return;
- const result = KeystoreAliasSchema.safeParse(keystoreAlias);
- if (!result.success) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- path: ["syncOptions", "keystoreAlias"],
- message: result.error.issues[0]?.message ?? "Invalid keystore alias"
- });
+ if (!data.destination || !isServerDestination(data.destination)) return [];
+ if (!isKeystoreExportFormat(exportFormat)) return [];
+
+ const issues: TKeystoreFieldIssue[] = [];
+ const password = (data.credentials as { exportPassword?: string } | undefined)?.exportPassword;
+ if (!password) {
+ if (requirePassword) {
+ issues.push({
+ path: ["credentials", "exportPassword"],
+ message: KEYSTORE_PASSWORD_REQUIRED_MESSAGE
+ });
+ }
+ } else {
+ const result = ExportPasswordSchema.safeParse(password);
+ if (!result.success) {
+ issues.push({
+ path: ["credentials", "exportPassword"],
+ message: result.error.issues[0]?.message ?? "Invalid export password"
+ });
+ }
+ }
+ if (keystoreAlias) {
+ const result = KeystoreAliasSchema.safeParse(keystoreAlias);
+ if (!result.success) {
+ issues.push({
+ path: ["syncOptions", "keystoreAlias"],
+ message: result.error.issues[0]?.message ?? "Invalid keystore alias"
+ });
+ }
}
+ return issues;
+};
+
+const refineKeystoreFields = (
+ data: { destination: PkiSync; syncOptions?: unknown; credentials?: unknown },
+ ctx: z.RefinementCtx,
+ options: { requirePassword: boolean }
+) => {
+ getKeystoreFieldIssues(data, options).forEach(({ path, message }) =>
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path, message })
+ );
};
// Drops keystore options the chosen format does not use, since the API rejects them.
@@ -205,26 +212,12 @@ export const PkiSyncFormSchema = PkiSyncUnionSchema.superRefine((data, ctx) => {
});
}
- if (
- isServerSyncForm(data) &&
- isKeystoreExportFormat(data.syncOptions?.exportFormat) &&
- !data.credentials?.exportPassword
- ) {
- ctx.addIssue({
- code: z.ZodIssueCode.custom,
- path: ["credentials", "exportPassword"],
- message: KEYSTORE_PASSWORD_REQUIRED_MESSAGE
- });
- }
-
- refineExportPassword(data, ctx);
- refineKeystoreAlias(data, ctx);
+ refineKeystoreFields(data, ctx, { requirePassword: true });
refineTargetHost(data, ctx);
});
export const UpdatePkiSyncFormSchema = UpdatePkiSyncUnionSchema.superRefine((data, ctx) => {
- refineExportPassword(data, ctx);
- refineKeystoreAlias(data, ctx);
+ refineKeystoreFields(data, ctx, { requirePassword: false });
refineTargetHost(data, ctx);
});
diff --git a/frontend/src/helpers/pkiSyncs.ts b/frontend/src/helpers/pkiSyncs.ts
index 6c378ce899..065dd4470c 100644
--- a/frontend/src/helpers/pkiSyncs.ts
+++ b/frontend/src/helpers/pkiSyncs.ts
@@ -1,5 +1,11 @@
import { AppConnection } from "@app/hooks/api/appConnections";
-import { HostCommandVariable, PkiSync, PkiSyncStatus } from "@app/hooks/api/pkiSyncs";
+import {
+ HostCommandVariable,
+ isKeystoreExportFormat,
+ PkiSync,
+ PkiSyncExportFormat,
+ PkiSyncStatus
+} from "@app/hooks/api/pkiSyncs";
export const PKI_SYNC_MAP: Record<
PkiSync,
@@ -184,6 +190,17 @@ export const VALUE_SYNC_OPTION_FIELDS = [
{ key: "group", label: "Group" }
] as const;
+export const getUnusedExportOptionKeys = (exportFormat?: PkiSyncExportFormat): Set<string> => {
+ if (!exportFormat) return new Set();
+ return new Set([
+ ...(exportFormat === PkiSyncExportFormat.Pem
+ ? []
+ : ["combineCertificateChain", "pemCertificateExtension"]),
+ ...(isKeystoreExportFormat(exportFormat) ? [] : ["keystoreAlias"]),
+ ...(exportFormat === PkiSyncExportFormat.Jks ? [] : ["includeTruststore"])
+ ]);
+};
+
export const POST_SYNC_COMMAND_VARIABLE_DESCRIPTIONS: Record<HostCommandVariable, string> = {
[HostCommandVariable.CertificatePath]: "Full path of the certificate file delivered this run",
[HostCommandVariable.CertificateDirectory]: "The destination directory",
@@ -233,9 +250,3 @@ export const getPkiSyncFailureMessage = (
return message;
}
};
-
-// A sync that succeeded can still carry a message, such as files it could not clean up.
-export const getPkiSyncWarningMessage = (
- status: PkiSyncStatus | null | undefined,
- message: string | null | undefined
-): string | null => (status === PkiSyncStatus.Succeeded && message ? message : null);
diff --git a/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDetailsSection.tsx b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDetailsSection.tsx
index 079f8b5d73..b476f0c6e2 100644
--- a/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDetailsSection.tsx
+++ b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncDetailsSection.tsx
@@ -3,7 +3,7 @@ import { BanIcon, RefreshCwIcon } from "lucide-react";
import { PkiSyncStatusBadge } from "@app/components/pki-syncs";
import { Badge, Detail, DetailLabel, DetailValue } from "@app/components/v3";
-import { getPkiSyncFailureMessage, getPkiSyncWarningMessage } from "@app/helpers/pkiSyncs";
+import { getPkiSyncFailureMessage } from "@app/helpers/pkiSyncs";
import { TPkiSync } from "@app/hooks/api/pkiSyncs";
import { SyncErrorDetail } from "./SyncErrorDetail";
@@ -16,7 +16,6 @@ export const PkiSyncDetailsSection = ({ pkiSync }: Props) => {
const { syncStatus, lastSyncMessage, lastSyncedAt, isAutoSyncEnabled } = pkiSync;
const failureMessage = getPkiSyncFailureMessage(syncStatus, lastSyncMessage);
- const warningMessage = getPkiSyncWarningMessage(syncStatus, lastSyncMessage);
return (
<>
@@ -51,9 +50,6 @@ export const PkiSyncDetailsSection = ({ pkiSync }: Props) => {
</Detail>
)}
{failureMessage && <SyncErrorDetail label="Last Sync Error" message={failureMessage} />}
- {warningMessage && (
- <SyncErrorDetail label="Last Sync Warning" message={warningMessage} variant="warning" />
- )}
</>
);
};
diff --git a/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncOptionsSection/PkiSyncOptionsSection.tsx b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncOptionsSection/PkiSyncOptionsSection.tsx
index f078f68f9e..dca4302f4d 100644
--- a/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncOptionsSection/PkiSyncOptionsSection.tsx
+++ b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/PkiSyncOptionsSection/PkiSyncOptionsSection.tsx
@@ -10,8 +10,12 @@ import {
DetailValue,
Separator
} from "@app/components/v3";
-import { BOOLEAN_SYNC_OPTION_FIELDS, VALUE_SYNC_OPTION_FIELDS } from "@app/helpers/pkiSyncs";
-import { TPkiSync } from "@app/hooks/api/pkiSyncs";
+import {
+ BOOLEAN_SYNC_OPTION_FIELDS,
+ getUnusedExportOptionKeys,
+ VALUE_SYNC_OPTION_FIELDS
+} from "@app/helpers/pkiSyncs";
+import { PkiSyncExportFormat, TPkiSync } from "@app/hooks/api/pkiSyncs";
type Props = {
pkiSync: TPkiSync;
@@ -21,6 +25,9 @@ const DESTINATION_OWNED_OPTIONS = new Set<string>(["exportFormat"]);
export const PkiSyncOptionsSection = ({ pkiSync }: Props) => {
const syncOptions = pkiSync.syncOptions as Record<string, unknown> | undefined;
+ const unusedOptionKeys = getUnusedExportOptionKeys(
+ syncOptions?.exportFormat as PkiSyncExportFormat | undefined
+ );
return (
<>
@@ -32,7 +39,7 @@ export const PkiSyncOptionsSection = ({ pkiSync }: Props) => {
<DetailGroup>
{BOOLEAN_SYNC_OPTION_FIELDS.map(({ key, label }) => {
const value = syncOptions?.[key];
- if (typeof value !== "boolean") return null;
+ if (typeof value !== "boolean" || unusedOptionKeys.has(key)) return null;
return (
<Detail key={key}>
@@ -46,7 +53,7 @@ export const PkiSyncOptionsSection = ({ pkiSync }: Props) => {
);
})}
{VALUE_SYNC_OPTION_FIELDS.map(({ key, label }) => {
- if (DESTINATION_OWNED_OPTIONS.has(key)) return null;
+ if (DESTINATION_OWNED_OPTIONS.has(key) || unusedOptionKeys.has(key)) return null;
const value = syncOptions?.[key];
if (value === undefined || value === null || value === "") return null;
diff --git a/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/SyncErrorDetail.tsx b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/SyncErrorDetail.tsx
index dd1f23b626..c2e99e0fb2 100644
--- a/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/SyncErrorDetail.tsx
+++ b/frontend/src/pages/cert-manager/PkiSyncDetailsByIDPage/components/SyncErrorDetail.tsx
@@ -3,14 +3,11 @@ import { Detail, DetailLabel, DetailValue } from "@app/components/v3";
type Props = {
label: string;
message: string;
- variant?: "danger" | "warning";
};
-export const SyncErrorDetail = ({ label, message, variant = "danger" }: Props) => (
+export const SyncErrorDetail = ({ label, message }: Props) => (
<Detail>
- <DetailLabel className={variant === "warning" ? "text-warning" : "text-danger"}>
- {label}
- </DetailLabel>
+ <DetailLabel className="text-danger">{label}</DetailLabel>
<DetailValue>
<p className="rounded-sm bg-surface-active p-2 text-xs break-words">{message}</p>
</DetailValue>