Skip to content

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

Address PR comments

Carlos Monastyrskib4f5834bb0f6
diff --git a/backend/src/services/certificate-authority/azure-ad-cs/azure-ad-cs-certificate-authority-fns.ts b/backend/src/services/certificate-authority/azure-ad-cs/azure-ad-cs-certificate-authority-fns.ts
index a26c7e15c0..9de2ca0ef3 100644
--- a/backend/src/services/certificate-authority/azure-ad-cs/azure-ad-cs-certificate-authority-fns.ts
+++ b/backend/src/services/certificate-authority/azure-ad-cs/azure-ad-cs-certificate-authority-fns.ts
@@ -17,6 +17,7 @@ import {
} from "@app/services/app-connection/azure-adcs/azure-adcs-connection-fns";
import { TCertificateBodyDALFactory } from "@app/services/certificate/certificate-body-dal";
import { TCertificateDALFactory } from "@app/services/certificate/certificate-dal";
+import { splitPemChain } from "@app/services/certificate/certificate-fns";
import { TCertificateSecretDALFactory } from "@app/services/certificate/certificate-secret-dal";
import {
CertExtendedKeyUsage,
@@ -366,10 +367,10 @@ const submitCertificateRequest = async (
}
// Check for immediate certificate issuance
- const certMatch = responseText.match(new RE2("-----BEGIN CERTIFICATE-----[\\s\\S]*?-----END CERTIFICATE-----"));
+ const [certMatch] = splitPemChain(responseText);
if (certMatch) {
// Clean up the certificate format
- certificate = certMatch[0].replace(new RE2("\\\\r\\\\n", "g"), "\n").replace(new RE2("\\\\r", "g"), "\n").trim();
+ certificate = certMatch.replace(new RE2("\\\\r\\\\n", "g"), "\n").replace(new RE2("\\\\r", "g"), "\n").trim();
// Validate the certificate format before using it
try {
diff --git a/backend/src/services/certificate-authority/ca-auto-renewal-queue.ts b/backend/src/services/certificate-authority/ca-auto-renewal-queue.ts
index eded800c7d..ab456a2a19 100644
--- a/backend/src/services/certificate-authority/ca-auto-renewal-queue.ts
+++ b/backend/src/services/certificate-authority/ca-auto-renewal-queue.ts
@@ -1,6 +1,4 @@
/* eslint-disable no-continue, no-await-in-loop */
-import RE2 from "re2";
-
import { TGatewayPoolServiceFactory } from "@app/ee/services/gateway-pool/gateway-pool-service";
import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";
import { CronJobName, TCronJobFactory } from "@app/lib/cron/cron-job";
@@ -12,6 +10,7 @@ import { TAppConnectionDALFactory } from "../app-connection/app-connection-dal";
import { decryptAppConnectionCredentials } from "../app-connection/app-connection-fns";
import { getAzureADCSConnectionCredentials } from "../app-connection/azure-adcs/azure-adcs-connection-fns";
import { TVenafiConnection } from "../app-connection/venafi/venafi-connection-types";
+import { splitPemChain } from "../certificate/certificate-fns";
import { TKmsServiceFactory } from "../kms/kms-service";
import { submitCsrToNativeAdcs } from "./ca-signing-config/adcs-native-signing-fns";
import { submitCsrToAdcs } from "./ca-signing-config/adcs-signing-fns";
@@ -51,7 +50,6 @@ export type TCaAutoRenewalQueueFactory = ReturnType<typeof caAutoRenewalQueueFac
const BATCH_SIZE = 100;
const MAX_RENEWAL_MESSAGE_LENGTH = 1024;
-const PEM_CERT_REGEX = new RE2("-----BEGIN CERTIFICATE-----[\\s\\S]*?-----END CERTIFICATE-----", "g");
export const caAutoRenewalQueueFactory = ({
queueService,
@@ -146,13 +144,12 @@ export const caAutoRenewalQueueFactory = ({
certificateId
});
- const pemCerts = PEM_CERT_REGEX.match(pemBundle);
- if (!pemCerts || pemCerts.length === 0) {
+ const [certificate, ...chainCerts] = splitPemChain(pemBundle);
+ if (!certificate) {
throw new Error("Failed to parse certificate from Venafi response");
}
- const certificate = pemCerts[0];
- const certificateChain = pemCerts.slice(1).join("\n");
+ const certificateChain = chainCerts.join("\n");
await internalCertificateAuthorityService.importCertToCa({
isInternal: true,
diff --git a/backend/src/services/certificate-authority/ca-signing-config/adcs-signing-fns.ts b/backend/src/services/certificate-authority/ca-signing-config/adcs-signing-fns.ts
index f118df46d0..03edeb3214 100644
--- a/backend/src/services/certificate-authority/ca-signing-config/adcs-signing-fns.ts
+++ b/backend/src/services/certificate-authority/ca-signing-config/adcs-signing-fns.ts
@@ -5,6 +5,7 @@ import RE2 from "re2";
import { BadRequestError } from "@app/lib/errors";
import { logger } from "@app/lib/logger";
import { createAdcsHttpClient } from "@app/services/app-connection/azure-adcs/azure-adcs-connection-fns";
+import { splitPemChain } from "@app/services/certificate/certificate-fns";
const POLL_INTERVAL_MS = 5000;
const MAX_POLL_ATTEMPTS = 120;
@@ -16,7 +17,6 @@ const RE_BASE64_WRAP = new RE2("(.{64})", "g");
const RE_CSR_BEGIN = new RE2("-----BEGIN CERTIFICATE REQUEST-----", "g");
const RE_CSR_END = new RE2("-----END CERTIFICATE REQUEST-----", "g");
const RE_CSR_NEWLINES = new RE2("\\r?\\n", "g");
-const RE_PEM_CERT = new RE2("-----BEGIN CERTIFICATE-----[\\s\\S]*?-----END CERTIFICATE-----");
const RE_ESCAPED_CRLF = new RE2("\\\\r\\\\n", "g");
const RE_ESCAPED_CR = new RE2("\\\\r", "g");
const RE_CRLF = new RE2("[\\r\\n]", "g");
@@ -153,9 +153,9 @@ export const submitCsrToAdcs = async (params: {
}
// Check for immediate certificate issuance
- const certMatch = responseText.match(RE_PEM_CERT);
+ const [certMatch] = splitPemChain(responseText);
if (certMatch) {
- certificate = certMatch[0].replace(RE_ESCAPED_CRLF, "\n").replace(RE_ESCAPED_CR, "\n").trim();
+ certificate = certMatch.replace(RE_ESCAPED_CRLF, "\n").replace(RE_ESCAPED_CR, "\n").trim();
status = "issued";
}
diff --git a/backend/src/services/certificate-authority/digicert/digicert-certificate-authority-shared.ts b/backend/src/services/certificate-authority/digicert/digicert-certificate-authority-shared.ts
index a7296f7c98..ceda3b93d8 100644
--- a/backend/src/services/certificate-authority/digicert/digicert-certificate-authority-shared.ts
+++ b/backend/src/services/certificate-authority/digicert/digicert-certificate-authority-shared.ts
@@ -1,5 +1,4 @@
import * as x509 from "@peculiar/x509";
-import RE2 from "re2";
import { BadRequestError, NotFoundError } from "@app/lib/errors";
import { TAppConnectionDALFactory } from "@app/services/app-connection/app-connection-dal";
@@ -7,6 +6,7 @@ import { AppConnection } from "@app/services/app-connection/app-connection-enums
import { decryptAppConnectionCredentials } from "@app/services/app-connection/app-connection-fns";
import { getDigiCertApiBaseUrl } from "@app/services/app-connection/digicert/digicert-connection-fns";
import { TDigiCertConnection } from "@app/services/app-connection/digicert/digicert-connection-types";
+import { splitPemChain } from "@app/services/certificate/certificate-fns";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
import { TCertificateAuthorityDALFactory } from "../certificate-authority-dal";
@@ -14,8 +14,6 @@ import { CaStatus, CaType } from "../certificate-authority-enums";
import { DigiCertCaPurpose } from "./digicert-certificate-authority-schemas";
import { TDigiCertCertificateAuthority } from "./digicert-certificate-authority-types";
-const PEM_CERTIFICATE_RE2 = new RE2("-----BEGIN CERTIFICATE-----[\\s\\S]*?-----END CERTIFICATE-----", "g");
-
export const castDbEntryToDigiCertCertificateAuthority = (
ca: Awaited<ReturnType<TCertificateAuthorityDALFactory["findByIdWithAssociatedCa"]>>
): TDigiCertCertificateAuthority & { credentials: Buffer | null | undefined } => {
@@ -95,7 +93,7 @@ export const getDigiCertClientCredentials = async (
};
export const extractLeafAndChain = (pemBundle: string): { leaf: string; chain: string } => {
- const matches = pemBundle.match(PEM_CERTIFICATE_RE2);
+ const matches = splitPemChain(pemBundle);
if (!matches || matches.length === 0) {
throw new BadRequestError({ message: "DigiCert returned an empty certificate bundle" });
}
diff --git a/backend/src/services/certificate-authority/venafi-tpp/venafi-tpp-certificate-authority-fns.ts b/backend/src/services/certificate-authority/venafi-tpp/venafi-tpp-certificate-authority-fns.ts
index d8ed5e434e..fa70eeeb58 100644
--- a/backend/src/services/certificate-authority/venafi-tpp/venafi-tpp-certificate-authority-fns.ts
+++ b/backend/src/services/certificate-authority/venafi-tpp/venafi-tpp-certificate-authority-fns.ts
@@ -23,6 +23,7 @@ import {
} from "@app/services/app-connection/venafi-tpp/venafi-tpp-connection-fns";
import { TCertificateBodyDALFactory } from "@app/services/certificate/certificate-body-dal";
import { TCertificateDALFactory } from "@app/services/certificate/certificate-dal";
+import { splitPemChain } from "@app/services/certificate/certificate-fns";
import { TCertificateSecretDALFactory } from "@app/services/certificate/certificate-secret-dal";
import {
CertExtendedKeyUsage,
@@ -276,19 +277,18 @@ const retrieveCertificateFromTpp = async ({
const decodedData = Buffer.from(data.CertificateData, "base64").toString("utf8");
- const certBlocks = decodedData.match(new RE2("-----BEGIN CERTIFICATE-----[\\s\\S]*?-----END CERTIFICATE-----", "g"));
+ const [leafCert, ...chainBlocks] = splitPemChain(decodedData);
- if (!certBlocks || certBlocks.length === 0) {
+ if (!leafCert) {
throw new BadRequestError({ message: "Failed to parse certificate data from Venafi TPP response" });
}
- const leafCert = certBlocks[0];
- const chainCerts = certBlocks.length > 1 ? certBlocks.slice(1).join("\n") : "";
+ const chainCerts = chainBlocks.join("\n");
logger.info(
{
certificateDN,
- chainCertCount: certBlocks.length - 1
+ chainCertCount: chainBlocks.length
},
"Venafi TPP: Certificate retrieved successfully"
);
@@ -724,14 +724,12 @@ export const VenafiTppCertificateAuthorityFns = ({
if (requestResponse.CertificateData) {
const decodedData = Buffer.from(requestResponse.CertificateData, "base64").toString("utf8");
- const certBlocks = decodedData.match(
- new RE2("-----BEGIN CERTIFICATE-----[\\s\\S]*?-----END CERTIFICATE-----", "g")
- );
+ const [leafCert, ...chainBlocks] = splitPemChain(decodedData);
- if (certBlocks && certBlocks.length > 0) {
+ if (leafCert) {
certificateResult = {
- certificate: certBlocks[0],
- chain: certBlocks.length > 1 ? certBlocks.slice(1).join("\n") : ""
+ certificate: leafCert,
+ chain: chainBlocks.join("\n")
};
}
}
diff --git a/backend/src/services/certificate/certificate-fns.test.ts b/backend/src/services/certificate/certificate-fns.test.ts
index f4a8013c38..9a5f6168bb 100644
--- a/backend/src/services/certificate/certificate-fns.test.ts
+++ b/backend/src/services/certificate/certificate-fns.test.ts
@@ -1,6 +1,6 @@
import { BadRequestError } from "@app/lib/errors";
-import { CertificateThumbprintAlgorithm, normalizeThumbprint } from "./certificate-fns";
+import { buildCertificateBundle, CertificateThumbprintAlgorithm, normalizeThumbprint } from "./certificate-fns";
describe("normalizeThumbprint", () => {
const sha1Hex = "a".repeat(40);
@@ -31,3 +31,13 @@ describe("normalizeThumbprint", () => {
expect(() => normalizeThumbprint("abc123")).toThrow(BadRequestError);
});
});
+
+describe("buildCertificateBundle", () => {
+ test("bundles cert + key when no chain is present", () => {
+ expect(buildCertificateBundle("CERT", "KEY")).toBe("CERT\nKEY\n");
+ });
+
+ test("includes the chain between the leaf and the key when present", () => {
+ expect(buildCertificateBundle("CERT", "KEY", "CHAIN")).toBe("CERT\nCHAIN\nKEY\n");
+ });
+});
diff --git a/backend/src/services/certificate/certificate-fns.ts b/backend/src/services/certificate/certificate-fns.ts
index 3e62cbcc40..dd6e59a66d 100644
--- a/backend/src/services/certificate/certificate-fns.ts
+++ b/backend/src/services/certificate/certificate-fns.ts
@@ -76,6 +76,17 @@ export const constructPemChainFromCerts = (certificates: x509.X509Certificate[])
export const prependCertToPemChain = (cert: x509.X509Certificate, pemChain: string) =>
`${cert.toString("pem")}\n${pemChain}`;
+// Concatenates a certificate, its chain, and its private key into a single PEM bundle. Used by sync
+// destinations that upload the full certificate as one file.
+export const buildCertificateBundle = (cert: string, privateKey: string, certificateChain?: string): string => {
+ const parts = [cert.trim()];
+ if (certificateChain) {
+ parts.push(certificateChain.trim());
+ }
+ parts.push(privateKey.trim());
+ return `${parts.join("\n")}\n`;
+};
+
export const splitPemChain = (pemText: string) => {
const re2Pattern = new RE2("-----BEGIN CERTIFICATE-----[^-]+-----END CERTIFICATE-----", "g");
diff --git a/backend/src/services/pki-sync/chef/chef-pki-sync-schemas.ts b/backend/src/services/pki-sync/chef/chef-pki-sync-schemas.ts
index 41c8f6c177..078910ecb3 100644
--- a/backend/src/services/pki-sync/chef/chef-pki-sync-schemas.ts
+++ b/backend/src/services/pki-sync/chef/chef-pki-sync-schemas.ts
@@ -4,7 +4,7 @@ import { openApiHidden } from "@app/server/lib/schemas";
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
import { buildCertificateNameSchemaTestName } from "@app/services/pki-sync/pki-sync-certificate-name-fns";
import { PkiSync } from "@app/services/pki-sync/pki-sync-enums";
-import { PkiSyncSchema } from "@app/services/pki-sync/pki-sync-schemas";
+import { BasePkiSyncOptionsSchema, PkiSyncSchema } from "@app/services/pki-sync/pki-sync-schemas";
import { CHEF_PKI_SYNC_CERTIFICATE_NAMING, CHEF_PKI_SYNC_DATA_BAG_NAMING } from "./chef-pki-sync-constants";
@@ -27,11 +27,8 @@ const ChefFieldMappingsSchema = z.object({
caCertificate: z.string().min(1, "CA certificate field name is required").default("ca_certificate")
});
-const ChefPkiSyncOptionsSchema = z.object({
+const ChefPkiSyncOptionsSchema = BasePkiSyncOptionsSchema.extend({
canImportCertificates: z.boolean().default(false),
- canRemoveCertificates: z.boolean().default(true),
- includeRootCa: z.boolean().default(false),
- preserveItemOnRenewal: z.boolean().default(true),
updateExistingCertificates: z.boolean().default(true),
certificateNameSchema: z
.string()
diff --git a/backend/src/services/pki-sync/f5-big-ip/f5-big-ip-pki-sync-schemas.ts b/backend/src/services/pki-sync/f5-big-ip/f5-big-ip-pki-sync-schemas.ts
index 5cac44a538..190b89c456 100644
--- a/backend/src/services/pki-sync/f5-big-ip/f5-big-ip-pki-sync-schemas.ts
+++ b/backend/src/services/pki-sync/f5-big-ip/f5-big-ip-pki-sync-schemas.ts
@@ -2,9 +2,12 @@ import { z } from "zod";
import { openApiHidden } from "@app/server/lib/schemas";
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
-import { buildCertificateNameSchemaTestName } from "@app/services/pki-sync/pki-sync-certificate-name-fns";
import { PkiSync } from "@app/services/pki-sync/pki-sync-enums";
-import { PkiSyncSchema } from "@app/services/pki-sync/pki-sync-schemas";
+import {
+ BasePkiSyncOptionsSchema,
+ buildDestinationCertificateNameSchema,
+ PkiSyncSchema
+} from "@app/services/pki-sync/pki-sync-schemas";
import { F5_BIG_IP_NAMING, F5BigIpProfileType } from "./f5-big-ip-pki-sync-constants";
@@ -53,29 +56,12 @@ export const F5BigIpPkiSyncConfigSchema = z
path: ["profileName"]
});
-export const F5BigIpPkiSyncOptionsSchema = z.object({
- canRemoveCertificates: z.boolean().default(true),
- includeRootCa: z.boolean().default(false),
- preserveItemOnRenewal: z.boolean().default(true),
- certificateNameSchema: z
- .string()
- .trim()
- .min(1, "Certificate name schema is required")
- .refine(
- (schema) => {
- const testName = buildCertificateNameSchemaTestName(schema);
-
- const hasForbiddenChars = F5_BIG_IP_NAMING.FORBIDDEN_CHARACTERS.split("").some((char) =>
- testName.includes(char)
- );
-
- return F5_BIG_IP_NAMING.NAME_PATTERN.test(testName) && !hasForbiddenChars;
- },
- {
- message:
- "Certificate name schema must result in names that contain only alphanumeric characters, hyphens (-), underscores (_), and periods (.) and be 1-255 characters long for F5 BIG-IP. Available placeholders: {{certificateId}}, {{shortCertificateId}}, {{profileId}}, {{applicationId}}, {{applicationName}}, {{commonName}}. A schema with no placeholder can be linked to only one certificate."
- }
- )
+export const F5BigIpPkiSyncOptionsSchema = BasePkiSyncOptionsSchema.extend({
+ certificateNameSchema: buildDestinationCertificateNameSchema({
+ naming: F5_BIG_IP_NAMING,
+ message:
+ "Certificate name schema must result in names that contain only alphanumeric characters, hyphens (-), underscores (_), and periods (.) and be 1-255 characters long for F5 BIG-IP. Available placeholders: {{certificateId}}, {{shortCertificateId}}, {{profileId}}, {{applicationId}}, {{applicationName}}, {{commonName}}. A schema with no placeholder can be linked to only one certificate."
+ })
});
export const F5BigIpPkiSyncSchema = PkiSyncSchema.extend({
diff --git a/backend/src/services/pki-sync/kemp-loadmaster/kemp-loadmaster-pki-sync-fns.test.ts b/backend/src/services/pki-sync/kemp-loadmaster/kemp-loadmaster-pki-sync-fns.test.ts
index 750fa72c40..60e5455007 100644
--- a/backend/src/services/pki-sync/kemp-loadmaster/kemp-loadmaster-pki-sync-fns.test.ts
+++ b/backend/src/services/pki-sync/kemp-loadmaster/kemp-loadmaster-pki-sync-fns.test.ts
@@ -1,11 +1,6 @@
import RE2 from "re2";
-import {
- buildCertificateBundle,
- buildIntermediateIdentifier,
- buildManagedCertNamePattern,
- splitPemChain
-} from "./kemp-loadmaster-pki-sync-fns";
+import { buildIntermediateIdentifier, buildManagedCertNamePattern } from "./kemp-loadmaster-pki-sync-fns";
const HEX = "550e8400e29b41d4a716446655440000";
@@ -46,35 +41,6 @@ describe("Kemp buildManagedCertNamePattern (orphan cleanup detection)", () => {
});
});
-describe("Kemp splitPemChain", () => {
- test("returns an empty array for missing or empty chains", () => {
- expect(splitPemChain(undefined)).toEqual([]);
- expect(splitPemChain("")).toEqual([]);
- });
-
- test("returns each CERTIFICATE block for single and multi-CA chains", () => {
- expect(splitPemChain(TEST_CA_PEM)).toHaveLength(1);
- expect(splitPemChain(`${TEST_CA_PEM}\n${TEST_CA_PEM}`)).toHaveLength(2);
- });
-
- test("ignores non-certificate PEM blocks (e.g. private keys)", () => {
- const withKey = `${TEST_CA_PEM}\n-----BEGIN PRIVATE KEY-----\nabc\n-----END PRIVATE KEY-----`;
- expect(splitPemChain(withKey)).toHaveLength(1);
- });
-});
-
-describe("Kemp buildCertificateBundle", () => {
- test("bundles cert + key when no chain is present", () => {
- const bundle = buildCertificateBundle("CERT", "KEY");
- expect(bundle).toBe("CERT\nKEY\n");
- });
-
- test("includes the chain between the leaf and the key when present", () => {
- const bundle = buildCertificateBundle("CERT", "KEY", "CHAIN");
- expect(bundle).toBe("CERT\nCHAIN\nKEY\n");
- });
-});
-
describe("Kemp buildIntermediateIdentifier", () => {
test("compiles {{fingerprint}} to a stable, content-addressed 24-char hex", () => {
const a = buildIntermediateIdentifier(TEST_CA_PEM, "Infisical-ca-{{fingerprint}}");
diff --git a/backend/src/services/pki-sync/kemp-loadmaster/kemp-loadmaster-pki-sync-fns.ts b/backend/src/services/pki-sync/kemp-loadmaster/kemp-loadmaster-pki-sync-fns.ts
index befdd61f58..45c2e8807f 100644
--- a/backend/src/services/pki-sync/kemp-loadmaster/kemp-loadmaster-pki-sync-fns.ts
+++ b/backend/src/services/pki-sync/kemp-loadmaster/kemp-loadmaster-pki-sync-fns.ts
@@ -17,6 +17,7 @@ import {
} from "@app/services/app-connection/kemp-loadmaster/kemp-loadmaster-connection-fns";
import { TKempLoadMasterConnection } from "@app/services/app-connection/kemp-loadmaster/kemp-loadmaster-connection-types";
import { TCertificateDALFactory } from "@app/services/certificate/certificate-dal";
+import { buildCertificateBundle, splitPemChain } from "@app/services/certificate/certificate-fns";
import { TCertificateSyncDALFactory } from "@app/services/certificate-sync/certificate-sync-dal";
import { CertificateSyncStatus } from "@app/services/certificate-sync/certificate-sync-enums";
import { TCertificateMap } from "@app/services/pki-sync/pki-sync-types";
@@ -61,23 +62,8 @@ const getKempCredentials = (pkiSync: TPkiSyncWithCredentials): TKempCredentials
return credentials;
};
-export const buildCertificateBundle = (cert: string, privateKey: string, certificateChain?: string): string => {
- const parts = [cert.trim()];
- if (certificateChain) {
- parts.push(certificateChain.trim());
- }
- parts.push(privateKey.trim());
- return `${parts.join("\n")}\n`;
-};
-
-const PEM_CERT_BLOCK = new RE2("-----BEGIN CERTIFICATE-----[\\s\\S]*?-----END CERTIFICATE-----", "g");
const WHITESPACE_SPLIT = new RE2("\\s+");
-export const splitPemChain = (chainPem?: string): string[] => {
- if (!chainPem) return [];
- return chainPem.match(PEM_CERT_BLOCK) ?? [];
-};
-
const extractCertNames = (data: unknown): Set<string> => {
const names = new Set<string>();
const certs = (data as { cert?: unknown } | undefined)?.cert;
@@ -356,6 +342,362 @@ export const kempLoadMasterPkiSyncFactory = ({
await setVirtualServiceCertFiles(makeRequest, baseUrl, headers, virtualServiceId, desired);
};
+ type TPreparedCertificate = {
+ targetIdentifier: string;
+ cert: string;
+ privateKey: string;
+ certificateChain?: string;
+ certificateId?: string;
+ isUpdate: boolean;
+ oldCertificateIdToRemove?: string;
+ };
+
+ // Resolves the target identifier for each certificate (handling renewal reuse/rename) and filters out
+ // certificates that cannot be synced (missing data, superseded by a renewal).
+ const prepareCertificatesForUpload = async (
+ pkiSync: TPkiSyncWithCredentials,
+ certificateMap: TCertificateMap,
+ existingCertNames: Set<string>,
+ syncRecordsByCertId: Map<string, TCertificateSyncs>,
+ options: { preserveItemOnRenewal: boolean; certificateNameSchema?: string }
+ ): Promise<{
+ certificatesToUpload: TPreparedCertificate[];
+ skippedCertificates: Array<{ name: string; reason: string }>;
+ }> => {
+ const { preserveItemOnRenewal, certificateNameSchema } = options;
+ const certificatesToUpload: TPreparedCertificate[] = [];
+ const skippedCertificates: Array<{ name: string; reason: string }> = [];
+
+ for (const [certName, certData] of Object.entries(certificateMap)) {
+ const { cert, privateKey, certificateChain, certificateId } = certData;
+
+ if (!cert || !privateKey) {
+ skippedCertificates.push({ name: certName, reason: "Missing certificate or private key data" });
+ // eslint-disable-next-line no-continue
+ continue;
+ }
+
+ let certificate: Awaited<ReturnType<typeof certificateDAL.findById>> | undefined;
+ if (typeof certificateId === "string") {
+ certificate = await certificateDAL.findById(certificateId);
+ if (certificate?.renewedByCertificateId) {
+ skippedCertificates.push({
+ name: certName,
+ reason: "Certificate has been renewed and replaced by a newer certificate"
+ });
+ // eslint-disable-next-line no-continue
+ continue;
+ }
+ }
+
+ let targetIdentifier = certName;
+ let isUpdate = false;
+ let oldCertificateIdToRemove: string | undefined;
+
+ if (typeof certificateId === "string") {
+ const syncRecordLookupId = certificate?.renewedFromCertificateId || certificateId;
+ const existingSyncRecord = syncRecordsByCertId.get(syncRecordLookupId);
+
+ if (certificate?.renewedFromCertificateId && preserveItemOnRenewal && existingSyncRecord?.externalIdentifier) {
+ targetIdentifier = existingSyncRecord.externalIdentifier;
+ isUpdate = true;
+ oldCertificateIdToRemove = certificate.renewedFromCertificateId;
+ } else if (certificate?.renewedFromCertificateId && !preserveItemOnRenewal) {
+ if (certificateNameSchema) {
+ targetIdentifier = compileCertificateNameSchema(
+ certificateNameSchema,
+ {
+ certificateId,
+ profileId: certData.profileId,
+ applicationId: pkiSync.applicationId,
+ applicationName: pkiSync.applicationName,
+ commonName: certData.commonName
+ },
+ PkiSync.KempLoadMaster
+ );
+ } else {
+ targetIdentifier = `Infisical-${certificateId.replace(DASH_GLOBAL, "")}`;
+ }
+ } else {
+ const directSyncRecord = syncRecordsByCertId.get(certificateId);
+ if (directSyncRecord?.externalIdentifier && existingCertNames.has(directSyncRecord.externalIdentifier)) {
+ targetIdentifier = directSyncRecord.externalIdentifier;
+ isUpdate = true;
+ }
+ }
+ }
+
+ certificatesToUpload.push({
+ targetIdentifier,
+ cert,
+ privateKey,
+ certificateChain,
+ certificateId,
+ isUpdate,
+ oldCertificateIdToRemove
+ });
+ }
+
+ return { certificatesToUpload, skippedCertificates };
+ };
+
+ // Uploads chain/CA certificates (when enabled) and the leaf certificate bundles to the LoadMaster,
+ // recording each result on the certificate-sync row.
+ const syncCertificatesToLoadMaster = async (
+ makeRequest: TKempRequestFn,
+ baseUrl: string,
+ headers: Record<string, string>,
+ pkiSync: TPkiSyncWithCredentials,
+ hostname: string,
+ certificatesToUpload: TPreparedCertificate[],
+ existingCertNames: Set<string>,
+ activeIdentifiers: Set<string>,
+ managedIdentifiers: Set<string>,
+ options: { caCertificateNameSchema: string }
+ ): Promise<{ uploaded: number; failedUploads: Array<{ name: string; error: string }> }> => {
+ const { caCertificateNameSchema } = options;
+ let uploaded = 0;
+ const failedUploads: Array<{ name: string; error: string }> = [];
+ const failedIntermediateIds = new Set<string>();
+
+ // Push each chain/CA cert into the LoadMaster's dedicated intermediate store
+ const existingIntermediateNames = await listIntermediateIdentifiers(makeRequest, baseUrl, headers);
+ const processedIntermediates = new Set<string>();
+ for (const { certificateChain } of certificatesToUpload) {
+ for (const intermediatePem of splitPemChain(certificateChain ?? "")) {
+ const intermediateId = buildIntermediateIdentifier(intermediatePem, caCertificateNameSchema);
+ if (processedIntermediates.has(intermediateId) || existingIntermediateNames.has(intermediateId)) {
+ // eslint-disable-next-line no-continue
+ continue;
+ }
+ processedIntermediates.add(intermediateId);
+ try {
+ await addIntermediateCertificate(makeRequest, baseUrl, headers, intermediateId, intermediatePem);
+ existingIntermediateNames.add(intermediateId);
+ logger.info(
+ `Kemp LoadMaster PKI sync [syncId=${pkiSync.id}]: ensured intermediate "${intermediateId}" on ${hostname}`
+ );
+ } catch (error: unknown) {
+ failedIntermediateIds.add(intermediateId);
+ logger.error(
+ { error },
+ `Kemp LoadMaster PKI sync [syncId=${pkiSync.id}]: failed to import intermediate "${intermediateId}"`
+ );
+ }
+ }
+ }
+
+ for (const {
+ targetIdentifier,
+ cert,
+ privateKey,
+ certificateChain,
+ certificateId,
+ isUpdate,
+ oldCertificateIdToRemove
+ } of certificatesToUpload) {
+ try {
+ const bundle = buildCertificateBundle(cert, privateKey, certificateChain);
+ await upsertCertificate(
+ makeRequest,
+ baseUrl,
+ headers,
+ targetIdentifier,
+ bundle,
+ existingCertNames.has(targetIdentifier)
+ );
+
+ existingCertNames.add(targetIdentifier);
+ activeIdentifiers.add(targetIdentifier);
+ managedIdentifiers.add(targetIdentifier);
+
+ const failedChainCaNames = failedIntermediateIds.size
+ ? splitPemChain(certificateChain ?? "")
+ .map((pem) => buildIntermediateIdentifier(pem, caCertificateNameSchema))
+ .filter((id) => failedIntermediateIds.has(id))
+ : [];
+ const caWarning = failedChainCaNames.length
+ ? ` (warning: could not push CA certificate(s) to the intermediate store: ${failedChainCaNames.join(", ")})`
+ : "";
+
+ if (certificateId) {
+ const existingCertSync = await certificateSyncDAL.findByPkiSyncAndCertificate(pkiSync.id, certificateId);
+
+ if (existingCertSync) {
+ await certificateSyncDAL.updateById(existingCertSync.id, {
+ externalIdentifier: targetIdentifier,
+ syncStatus: CertificateSyncStatus.Succeeded,
+ lastSyncMessage: `${
+ isUpdate
+ ? `Updated certificate on Kemp LoadMaster as "${targetIdentifier}"`
+ : `Synced certificate to Kemp LoadMaster as "${targetIdentifier}"`
+ }${caWarning}`,
+ lastSyncedAt: new Date()
+ });
+ } else {
+ await certificateSyncDAL.addCertificates(pkiSync.id, [
+ { certificateId, externalIdentifier: targetIdentifier }
+ ]);
+ }
+
+ if (oldCertificateIdToRemove) {
+ await certificateSyncDAL.removeCertificates(pkiSync.id, [oldCertificateIdToRemove]);
+ }
+ }
+
+ uploaded += 1;
+
+ logger.info(
+ `Kemp LoadMaster PKI sync [syncId=${pkiSync.id}]: ${isUpdate ? "updated" : "uploaded"} certificate "${targetIdentifier}" on ${hostname}`
+ );
+ } catch (error: unknown) {
+ const errorMessage = kempError(error, "Unknown error");
+ failedUploads.push({ name: targetIdentifier, error: errorMessage });
+
+ if (certificateId) {
+ const syncRecord = await certificateSyncDAL.findByPkiSyncAndCertificate(pkiSync.id, certificateId);
+ if (syncRecord) {
+ await certificateSyncDAL.updateById(syncRecord.id, {
+ syncStatus: CertificateSyncStatus.Failed,
+ lastSyncMessage: `Failed to sync to Kemp LoadMaster: ${errorMessage}`.slice(0, 4096)
+ });
+ }
+ }
+
+ logger.error(
+ { error },
+ `Kemp LoadMaster PKI sync [syncId=${pkiSync.id}]: failed to upload certificate "${targetIdentifier}"`
+ );
+ }
+ }
+
+ return { uploaded, failedUploads };
+ };
+
+ // Removes certificates that are no longer managed by this sync (unbinding them from the Virtual
+ // Service first, since the LoadMaster refuses to delete a bound certificate).
+ const cleanupOrphanedCertificates = async (
+ makeRequest: TKempRequestFn,
+ baseUrl: string,
+ headers: Record<string, string>,
+ pkiSync: TPkiSyncWithCredentials,
+ hostname: string,
+ context: {
+ certificateMap: TCertificateMap;
+ certificatesToUpload: TPreparedCertificate[];
+ existingSyncRecords: TCertificateSyncs[];
+ existingCertNames: Set<string>;
+ activeIdentifiers: Set<string>;
+ managedIdentifiers: Set<string>;
+ virtualServiceId?: string;
+ },
+ options: { canRemoveCertificates: boolean; certificateNameSchema?: string }
+ ): Promise<{ removed: number; failedRemovals: Array<{ name: string; error: string }> }> => {
+ const { canRemoveCertificates, certificateNameSchema } = options;
+ const {
+ certificateMap,
+ certificatesToUpload,
+ existingSyncRecords,
+ existingCertNames,
+ activeIdentifiers,
+ managedIdentifiers,
+ virtualServiceId
+ } = context;
+ let removed = 0;
+ const failedRemovals: Array<{ name: string; error: string }> = [];
+
+ // Certificates this sync still manages, so a cert whose upload failed this run is not mistaken
+ // for an orphan and deleted.
+ const managedCertificateIds = new Set<string>();
+ for (const certData of Object.values(certificateMap)) {
+ if (certData.certificateId) managedCertificateIds.add(certData.certificateId);
+ }
+ const attemptedIdentifiers = new Set(certificatesToUpload.map((entry) => entry.targetIdentifier));
+
+ const identifiersToRemove = new Set<string>();
+ if (canRemoveCertificates) {
+ for (const syncRecord of existingSyncRecords) {
+ if (
+ syncRecord.externalIdentifier &&
+ !activeIdentifiers.has(syncRecord.externalIdentifier) &&
+ existingCertNames.has(syncRecord.externalIdentifier) &&
+ !(syncRecord.certificateId && managedCertificateIds.has(syncRecord.certificateId))
+ ) {
+ identifiersToRemove.add(syncRecord.externalIdentifier);
+ }
+ }
+
+ // Catch certificates whose sync records were lost, by name pattern. Skip anything attempted
+ // this run so a failed upload is not treated as an orphan.
+ if (!certificateNameSchemaHasFreeTextPlaceholder(certificateNameSchema)) {
+ const managedCertNamePattern = buildManagedCertNamePattern(certificateNameSchema);
+ for (const certName of existingCertNames) {
+ if (
+ managedCertNamePattern.test(certName) &&
+ !activeIdentifiers.has(certName) &&
+ !attemptedIdentifiers.has(certName)
+ ) {
+ identifiersToRemove.add(certName);
+ }
+ }
+ }
+
+ identifiersToRemove.forEach((identifier) => managedIdentifiers.add(identifier));
+ }
+
+ // Reconcile the Virtual Service binding BEFORE deleting: the LoadMaster refuses to delete a
+ // certificate that is still bound, so removed certificates must be unbound here first.
+ let virtualServiceBindingError: string | undefined;
+ if (virtualServiceId) {
+ try {
+ await reconcileVirtualServiceBinding(
+ makeRequest,
+ baseUrl,
+ headers,
+ virtualServiceId,
+ activeIdentifiers,
+ managedIdentifiers,
+ canRemoveCertificates,
+ existingCertNames
+ );
+ } catch (error: unknown) {
+ virtualServiceBindingError = kempError(error, "Failed to bind certificates to the Virtual Service");
+ logger.error(
+ { error },
+ `Kemp LoadMaster PKI sync [syncId=${pkiSync.id}]: failed to bind certificates to Virtual Service ${virtualServiceId}`
+ );
+ }
+ }
+
+ for (const identifier of identifiersToRemove) {
+ try {
+ await deleteCertificate(makeRequest, baseUrl, headers, identifier);
+ removed += 1;
+
+ logger.info(
+ `Kemp LoadMaster PKI sync [syncId=${pkiSync.id}]: removed orphaned certificate "${identifier}" from ${hostname}`
+ );
+ } catch (error: unknown) {
+ failedRemovals.push({ name: identifier, error: kempError(error, "Unknown error") });
+ logger.error(
+ { error },
+ `Kemp LoadMaster PKI sync [syncId=${pkiSync.id}]: failed to remove certificate "${identifier}"`
+ );
+ }
+ }
+
+ // Leaves are already uploaded, so a binding failure can't block them; but it must surface as a
+ // failed sync
+ if (virtualServiceBindingError) {
+ throw new PkiSyncError({
+ message: `Failed to bind certificates to Virtual Service ${virtualServiceId}: ${virtualServiceBindingError}`,
+ shouldRetry: false
+ });
+ }
+
+ return { removed, failedRemovals };
+ };
+
const syncCertificates = async (
pkiSync: TPkiSyncWithCredentials,
certificateMap: TCertificateMap
@@ -377,11 +719,9 @@ export const kempLoadMasterPkiSyncFactory = ({
certificateNameSchema?: string;
canRemoveCertificates?: boolean;
preserveItemOnRenewal?: boolean;
- syncCaCertificates?: boolean;
caCertificateNameSchema?: string;
}
| undefined;
- const syncCaCertificates = syncOptions?.syncCaCertificates ?? true;
const caCertificateNameSchema = syncOptions?.caCertificateNameSchema || KEMP_LOADMASTER_DEFAULT_CA_NAME_SCHEMA;
const canRemoveCertificates = syncOptions?.canRemoveCertificates ?? true;
const preserveItemOnRenewal = syncOptions?.preserveItemOnRenewal ?? true;
@@ -396,312 +736,55 @@ export const kempLoadMasterPkiSyncFactory = ({
{ gatewayId: effectiveGatewayId, credentials },
gatewayV2Service,
async (makeRequest) => {
- let uploaded = 0;
- let removed = 0;
- const failedUploads: Array<{ name: string; error: string }> = [];
- const failedRemovals: Array<{ name: string; error: string }> = [];
- const skippedCertificates: Array<{ name: string; reason: string }> = [];
- const failedIntermediateIds = new Set<string>();
-
const existingCertNames = await listCertificateIdentifiers(makeRequest, baseUrl, headers);
-
const existingSyncRecords = await certificateSyncDAL.findByPkiSyncId(pkiSync.id);
+
const syncRecordsByCertId = new Map<string, TCertificateSyncs>();
+ const managedIdentifiers = new Set<string>();
existingSyncRecords.forEach((record: TCertificateSyncs) => {
- if (record.certificateId) {
- syncRecordsByCertId.set(record.certificateId, record);
- }
+ if (record.certificateId) syncRecordsByCertId.set(record.certificateId, record);
+ if (record.externalIdentifier) managedIdentifiers.add(record.externalIdentifier);
});
-
const activeIdentifiers = new Set<string>();
- const managedIdentifiers = new Set<string>();
- existingSyncRecords.forEach((record) => {
- if (record.externalIdentifier) {
- managedIdentifiers.add(record.externalIdentifier);
- }
- });
-
- const certificatesToUpload: Array<{
- targetIdentifier: string;
- cert: string;
- privateKey: string;
- certificateChain?: string;
- certificateId?: string;
- isUpdate: boolean;
- oldCertificateIdToRemove?: string;
- }> = [];
-
- for (const [certName, certData] of Object.entries(certificateMap)) {
- const { cert, privateKey, certificateChain, certificateId } = certData;
-
- if (!cert || !privateKey) {
- skippedCertificates.push({ name: certName, reason: "Missing certificate or private key data" });
- // eslint-disable-next-line no-continue
- continue;
- }
-
- let certificate: Awaited<ReturnType<typeof certificateDAL.findById>> | undefined;
- if (typeof certificateId === "string") {
- certificate = await certificateDAL.findById(certificateId);
- if (certificate?.renewedByCertificateId) {
- skippedCertificates.push({
- name: certName,
- reason: "Certificate has been renewed and replaced by a newer certificate"
- });
- // eslint-disable-next-line no-continue
- continue;
- }
- }
-
- let targetIdentifier = certName;
- let isUpdate = false;
- let oldCertificateIdToRemove: string | undefined;
-
- if (typeof certificateId === "string") {
- const syncRecordLookupId = certificate?.renewedFromCertificateId || certificateId;
- const existingSyncRecord = syncRecordsByCertId.get(syncRecordLookupId);
-
- if (
- certificate?.renewedFromCertificateId &&
- preserveItemOnRenewal &&
- existingSyncRecord?.externalIdentifier
- ) {
- targetIdentifier = existingSyncRecord.externalIdentifier;
- isUpdate = true;
- oldCertificateIdToRemove = certificate.renewedFromCertificateId;
- } else if (certificate?.renewedFromCertificateId && !preserveItemOnRenewal) {
- if (certificateNameSchema) {
- targetIdentifier = compileCertificateNameSchema(
- certificateNameSchema,
- {
- certificateId,
- profileId: certData.profileId,
- applicationId: pkiSync.applicationId,
- applicationName: pkiSync.applicationName,
- commonName: certData.commonName
- },
- PkiSync.KempLoadMaster
- );
- } else {
- targetIdentifier = `Infisical-${certificateId.replace(DASH_GLOBAL, "")}`;
- }
- } else {
- const directSyncRecord = syncRecordsByCertId.get(certificateId);
- if (directSyncRecord?.externalIdentifier && existingCertNames.has(directSyncRecord.externalIdentifier)) {
- targetIdentifier = directSyncRecord.externalIdentifier;
- isUpdate = true;
- }
- }
- }
-
- certificatesToUpload.push({
- targetIdentifier,
- cert,
- privateKey,
- certificateChain,
- certificateId,
- isUpdate,
- oldCertificateIdToRemove
- });
- }
-
- // Push each chain/CA cert into the LoadMaster's dedicated intermediate store
- if (syncCaCertificates) {
- const existingIntermediateNames = await listIntermediateIdentifiers(makeRequest, baseUrl, headers);
- const processedIntermediates = new Set<string>();
- for (const { certificateChain } of certificatesToUpload) {
- for (const intermediatePem of splitPemChain(certificateChain)) {
- const intermediateId = buildIntermediateIdentifier(intermediatePem, caCertificateNameSchema);
- if (processedIntermediates.has(intermediateId) || existingIntermediateNames.has(intermediateId)) {
- // eslint-disable-next-line no-continue
- continue;
- }
- processedIntermediates.add(intermediateId);
- try {
- await addIntermediateCertificate(makeRequest, baseUrl, headers, intermediateId, intermediatePem);
- existingIntermediateNames.add(intermediateId);
- logger.info(
- `Kemp LoadMaster PKI sync [syncId=${pkiSync.id}]: ensured intermediate "${intermediateId}" on ${credentials.hostname}`
- );
- } catch (error: unknown) {
- failedIntermediateIds.add(intermediateId);
- logger.error(
- { error },
- `Kemp LoadMaster PKI sync [syncId=${pkiSync.id}]: failed to import intermediate "${intermediateId}"`
- );
- }
- }
- }
- }
-
- for (const {
- targetIdentifier,
- cert,
- privateKey,
- certificateChain,
- certificateId,
- isUpdate,
- oldCertificateIdToRemove
- } of certificatesToUpload) {
- try {
- const bundle = buildCertificateBundle(cert, privateKey, certificateChain);
- await upsertCertificate(
- makeRequest,
- baseUrl,
- headers,
- targetIdentifier,
- bundle,
- existingCertNames.has(targetIdentifier)
- );
-
- existingCertNames.add(targetIdentifier);
- activeIdentifiers.add(targetIdentifier);
- managedIdentifiers.add(targetIdentifier);
-
- const failedChainCaNames = failedIntermediateIds.size
- ? splitPemChain(certificateChain)
- .map((pem) => buildIntermediateIdentifier(pem, caCertificateNameSchema))
- .filter((id) => failedIntermediateIds.has(id))
- : [];
- const caWarning = failedChainCaNames.length
- ? ` (warning: could not push CA certificate(s) to the intermediate store: ${failedChainCaNames.join(", ")})`
- : "";
-
- if (certificateId) {
- const existingCertSync = await certificateSyncDAL.findByPkiSyncAndCertificate(pkiSync.id, certificateId);
-
- if (existingCertSync) {
- await certificateSyncDAL.updateById(existingCertSync.id, {
- externalIdentifier: targetIdentifier,
- syncStatus: CertificateSyncStatus.Succeeded,
- lastSyncMessage: `${
- isUpdate
- ? `Updated certificate on Kemp LoadMaster as "${targetIdentifier}"`
- : `Synced certificate to Kemp LoadMaster as "${targetIdentifier}"`
- }${caWarning}`,
- lastSyncedAt: new Date()
- });
- } else {
- await certificateSyncDAL.addCertificates(pkiSync.id, [
- { certificateId, externalIdentifier: targetIdentifier }
- ]);
- }
-
- if (oldCertificateIdToRemove) {
- await certificateSyncDAL.removeCertificates(pkiSync.id, [oldCertificateIdToRemove]);
- }
- }
-
- uploaded += 1;
-
- logger.info(
- `Kemp LoadMaster PKI sync [syncId=${pkiSync.id}]: ${isUpdate ? "updated" : "uploaded"} certificate "${targetIdentifier}" on ${credentials.hostname}`
- );
- } catch (error: unknown) {
- const errorMessage = kempError(error, "Unknown error");
- failedUploads.push({ name: targetIdentifier, error: errorMessage });
-
- if (certificateId) {
- const syncRecord = await certificateSyncDAL.findByPkiSyncAndCertificate(pkiSync.id, certificateId);
- if (syncRecord) {
- await certificateSyncDAL.updateById(syncRecord.id, {
- syncStatus: CertificateSyncStatus.Failed,
- lastSyncMessage: `Failed to sync to Kemp LoadMaster: ${errorMessage}`.slice(0, 4096)
- });
- }
- }
- logger.error(
- { error },
- `Kemp LoadMaster PKI sync [syncId=${pkiSync.id}]: failed to upload certificate "${targetIdentifier}"`
- );
- }
- }
-
- const managedCertificateIds = new Set<string>();
- for (const certData of Object.values(certificateMap)) {
- if (certData.certificateId) managedCertificateIds.add(certData.certificateId);
- }
- const attemptedIdentifiers = new Set(certificatesToUpload.map((entry) => entry.targetIdentifier));
-
- const identifiersToRemove = new Set<string>();
- if (canRemoveCertificates) {
- for (const syncRecord of existingSyncRecords) {
- if (
- syncRecord.externalIdentifier &&
- !activeIdentifiers.has(syncRecord.externalIdentifier) &&
- existingCertNames.has(syncRecord.externalIdentifier) &&
- !(syncRecord.certificateId && managedCertificateIds.has(syncRecord.certificateId))
- ) {
- identifiersToRemove.add(syncRecord.externalIdentifier);
- }
- }
-
- if (!certificateNameSchemaHasFreeTextPlaceholder(certificateNameSchema)) {
- const managedCertNamePattern = buildManagedCertNamePattern(certificateNameSchema);
- for (const certName of existingCertNames) {
- if (
- managedCertNamePattern.test(certName) &&
- !activeIdentifiers.has(certName) &&
- !attemptedIdentifiers.has(certName)
- ) {
- identifiersToRemove.add(certName);
- }
- }
- }
-
- identifiersToRemove.forEach((identifier) => managedIdentifiers.add(identifier));
- }
-
- // Reconcile the Virtual Service binding BEFORE deleting: the LoadMaster refuses to delete a
- // certificate that is still bound, so removed certificates must be unbound here first.
- let virtualServiceBindingError: string | undefined;
- if (virtualServiceId) {
- try {
- await reconcileVirtualServiceBinding(
- makeRequest,
- baseUrl,
- headers,
- virtualServiceId,
- activeIdentifiers,
- managedIdentifiers,
- canRemoveCertificates,
- existingCertNames
- );
- } catch (error: unknown) {
- virtualServiceBindingError = kempError(error, "Failed to bind certificates to the Virtual Service");
- logger.error(
- { error },
- `Kemp LoadMaster PKI sync [syncId=${pkiSync.id}]: failed to bind certificates to Virtual Service ${virtualServiceId}`
- );
- }
- }
-
- for (const identifier of identifiersToRemove) {
- try {
- await deleteCertificate(makeRequest, baseUrl, headers, identifier);
- removed += 1;
-
- logger.info(
- `Kemp LoadMaster PKI sync [syncId=${pkiSync.id}]: removed orphaned certificate "${identifier}" from ${credentials.hostname}`
- );
- } catch (error: unknown) {
- failedRemovals.push({ name: identifier, error: kempError(error, "Unknown error") });
- logger.error(
- { error },
- `Kemp LoadMaster PKI sync [syncId=${pkiSync.id}]: failed to remove certificate "${identifier}"`
- );
- }
- }
-
- // Leaves are already uploaded, so a binding failure can't block them; but it must surface as a
- // failed sync
- if (virtualServiceBindingError) {
- throw new PkiSyncError({
- message: `Failed to bind certificates to Virtual Service ${virtualServiceId}: ${virtualServiceBindingError}`,
- shouldRetry: false
- });
- }
+ const { certificatesToUpload, skippedCertificates } = await prepareCertificatesForUpload(
+ pkiSync,
+ certificateMap,
+ existingCertNames,
+ syncRecordsByCertId,
+ { preserveItemOnRenewal, certificateNameSchema }
+ );
+
+ const { uploaded, failedUploads } = await syncCertificatesToLoadMaster(
+ makeRequest,
+ baseUrl,
+ headers,
+ pkiSync,
+ credentials.hostname,
+ certificatesToUpload,
+ existingCertNames,
+ activeIdentifiers,
+ managedIdentifiers,
+ { caCertificateNameSchema }
+ );
+
+ const { removed, failedRemovals } = await cleanupOrphanedCertificates(
+ makeRequest,
+ baseUrl,
+ headers,
+ pkiSync,
+ credentials.hostname,
+ {
+ certificateMap,
+ certificatesToUpload,
+ existingSyncRecords,
+ existingCertNames,
+ activeIdentifiers,
+ managedIdentifiers,
+ virtualServiceId
+ },
+ { canRemoveCertificates, certificateNameSchema }
+ );
return {
uploaded,
diff --git a/backend/src/services/pki-sync/kemp-loadmaster/kemp-loadmaster-pki-sync-schemas.test.ts b/backend/src/services/pki-sync/kemp-loadmaster/kemp-loadmaster-pki-sync-schemas.test.ts
index 77c9020aa8..778c2f2ff6 100644
--- a/backend/src/services/pki-sync/kemp-loadmaster/kemp-loadmaster-pki-sync-schemas.test.ts
+++ b/backend/src/services/pki-sync/kemp-loadmaster/kemp-loadmaster-pki-sync-schemas.test.ts
@@ -34,14 +34,13 @@ describe("Kemp LoadMaster certificateNameSchema validation", () => {
});
});
-describe("Kemp LoadMaster caCertificateNameSchema + syncCaCertificates", () => {
+describe("Kemp LoadMaster caCertificateNameSchema", () => {
const acceptsCa = (caCertificateNameSchema: string) => parseOptions({ caCertificateNameSchema }).success;
test("applies sensible defaults when omitted", () => {
const result = parseOptions({});
expect(result.success).toBe(true);
if (result.success) {
- expect(result.data.syncCaCertificates).toBe(true);
expect(result.data.caCertificateNameSchema).toBe("Infisical-ca-{{fingerprint}}");
}
});
diff --git a/backend/src/services/pki-sync/kemp-loadmaster/kemp-loadmaster-pki-sync-schemas.ts b/backend/src/services/pki-sync/kemp-loadmaster/kemp-loadmaster-pki-sync-schemas.ts
index adfa353412..df02c3c92e 100644
--- a/backend/src/services/pki-sync/kemp-loadmaster/kemp-loadmaster-pki-sync-schemas.ts
+++ b/backend/src/services/pki-sync/kemp-loadmaster/kemp-loadmaster-pki-sync-schemas.ts
@@ -3,9 +3,12 @@ import { z } from "zod";
import { openApiHidden } from "@app/server/lib/schemas";
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
-import { buildCertificateNameSchemaTestName } from "@app/services/pki-sync/pki-sync-certificate-name-fns";
import { PkiSync } from "@app/services/pki-sync/pki-sync-enums";
-import { PkiSyncSchema } from "@app/services/pki-sync/pki-sync-schemas";
+import {
+ BasePkiSyncOptionsSchema,
+ buildDestinationCertificateNameSchema,
+ PkiSyncSchema
+} from "@app/services/pki-sync/pki-sync-schemas";
import { KEMP_LOADMASTER_DEFAULT_CA_NAME_SCHEMA, KEMP_LOADMASTER_NAMING } from "./kemp-loadmaster-pki-sync-constants";
@@ -22,11 +25,7 @@ export const KempLoadMasterPkiSyncConfigSchema = z.object({
.optional()
});
-export const KempLoadMasterPkiSyncOptionsSchema = z.object({
- canRemoveCertificates: z.boolean().default(true),
- includeRootCa: z.boolean().default(false),
- preserveItemOnRenewal: z.boolean().default(true),
- syncCaCertificates: z.boolean().default(true),
+export const KempLoadMasterPkiSyncOptionsSchema = BasePkiSyncOptionsSchema.extend({
caCertificateNameSchema: z
.string()
.trim()
@@ -46,28 +45,12 @@ export const KempLoadMasterPkiSyncOptionsSchema = z.object({
"CA certificate name schema must result in names 1-251 characters long containing only alphanumeric characters, hyphens (-), underscores (_), and periods (.). Available placeholders: {{fingerprint}} (recommended so each CA gets a unique name) and {{commonName}}. A schema with no placeholder can hold only one CA certificate. Defaults to Infisical-ca-{{fingerprint}}."
}
),
- certificateNameSchema: z
- .string()
- .trim()
- .min(1, "Certificate name schema is required")
- .refine(
- (schema) => {
- const testName = buildCertificateNameSchemaTestName(schema);
-
- const hasForbiddenChars = KEMP_LOADMASTER_NAMING.FORBIDDEN_CHARACTERS.split("").some((char) =>
- testName.includes(char)
- );
-
- const hasCertificateIdentifier =
- schema.includes("{{certificateId}}") || schema.includes("{{shortCertificateId}}");
-
- return hasCertificateIdentifier && KEMP_LOADMASTER_NAMING.NAME_PATTERN.test(testName) && !hasForbiddenChars;
- },
- {
- message:
- "Certificate name schema must include the {{certificateId}} or {{shortCertificateId}} placeholder so each certificate gets a unique identifier, contain only alphanumeric characters, hyphens (-), underscores (_), and periods (.), and be 1-251 characters long for Kemp LoadMaster. It can also include {{profileId}}, {{applicationId}}, {{applicationName}}, and {{commonName}} placeholders."
- }
- )
+ certificateNameSchema: buildDestinationCertificateNameSchema({
+ naming: KEMP_LOADMASTER_NAMING,
+ requireCertificateIdentifier: true,
+ message:
+ "Certificate name schema must include the {{certificateId}} or {{shortCertificateId}} placeholder so each certificate gets a unique identifier, contain only alphanumeric characters, hyphens (-), underscores (_), and periods (.), and be 1-251 characters long for Kemp LoadMaster. It can also include {{profileId}}, {{applicationId}}, {{applicationName}}, and {{commonName}} placeholders."
+ })
});
export const KempLoadMasterPkiSyncSchema = PkiSyncSchema.extend({
diff --git a/backend/src/services/pki-sync/netscaler/netscaler-pki-sync-schemas.ts b/backend/src/services/pki-sync/netscaler/netscaler-pki-sync-schemas.ts
index 9998cfab56..7f4e12ead5 100644
--- a/backend/src/services/pki-sync/netscaler/netscaler-pki-sync-schemas.ts
+++ b/backend/src/services/pki-sync/netscaler/netscaler-pki-sync-schemas.ts
@@ -2,9 +2,12 @@ import { z } from "zod";
import { openApiHidden } from "@app/server/lib/schemas";
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
-import { buildCertificateNameSchemaTestName } from "@app/services/pki-sync/pki-sync-certificate-name-fns";
import { PkiSync } from "@app/services/pki-sync/pki-sync-enums";
-import { PkiSyncSchema } from "@app/services/pki-sync/pki-sync-schemas";
+import {
+ BasePkiSyncOptionsSchema,
+ buildDestinationCertificateNameSchema,
+ PkiSyncSchema
+} from "@app/services/pki-sync/pki-sync-schemas";
import { NETSCALER_NAMING } from "./netscaler-pki-sync-constants";
@@ -12,29 +15,12 @@ export const NetScalerPkiSyncConfigSchema = z.object({
vserverName: z.string().max(127, "vServer name cannot exceed 127 characters").optional()
});
-export const NetScalerPkiSyncOptionsSchema = z.object({
- canRemoveCertificates: z.boolean().default(true),
- includeRootCa: z.boolean().default(false),
- preserveItemOnRenewal: z.boolean().default(true),
- certificateNameSchema: z
- .string()
- .trim()
- .min(1, "Certificate name schema is required")
- .refine(
- (schema) => {
- const testName = buildCertificateNameSchemaTestName(schema);
-
- const hasForbiddenChars = NETSCALER_NAMING.FORBIDDEN_CHARACTERS.split("").some((char) =>
- testName.includes(char)
- );
-
- return NETSCALER_NAMING.NAME_PATTERN.test(testName) && !hasForbiddenChars;
- },
- {
- message:
- "Certificate name schema must result in names that contain only alphanumeric characters, hyphens (-), underscores (_), and periods (.) and be 1-63 characters long for NetScaler. Available placeholders: {{certificateId}}, {{shortCertificateId}}, {{profileId}}, {{applicationId}}, {{applicationName}}, {{commonName}}. A schema with no placeholder can be linked to only one certificate."
- }
- )
+export const NetScalerPkiSyncOptionsSchema = BasePkiSyncOptionsSchema.extend({
+ certificateNameSchema: buildDestinationCertificateNameSchema({
+ naming: NETSCALER_NAMING,
+ message:
+ "Certificate name schema must result in names that contain only alphanumeric characters, hyphens (-), underscores (_), and periods (.) and be 1-63 characters long for NetScaler. Available placeholders: {{certificateId}}, {{shortCertificateId}}, {{profileId}}, {{applicationId}}, {{applicationName}}, {{commonName}}. A schema with no placeholder can be linked to only one certificate."
+ })
});
export const NetScalerPkiSyncSchema = PkiSyncSchema.extend({
diff --git a/backend/src/services/pki-sync/pki-sync-schemas.ts b/backend/src/services/pki-sync/pki-sync-schemas.ts
index 9fe07ca2d5..44aeb76ae9 100644
--- a/backend/src/services/pki-sync/pki-sync-schemas.ts
+++ b/backend/src/services/pki-sync/pki-sync-schemas.ts
@@ -1,8 +1,42 @@
import RE2 from "re2";
import { z } from "zod";
+import { buildCertificateNameSchemaTestName } from "./pki-sync-certificate-name-fns";
import { PkiSync } from "./pki-sync-enums";
+// Sync options shared by every destination. Destinations extend this with their own
+// certificateNameSchema and any extra options.
+export const BasePkiSyncOptionsSchema = z.object({
+ canRemoveCertificates: z.boolean().default(true),
+ includeRootCa: z.boolean().default(false),
+ preserveItemOnRenewal: z.boolean().default(true)
+});
+
+// Builds a destination's certificateNameSchema validator. The compiled name must match the
+// destination's character rules; pass requireCertificateIdentifier when every certificate must
+// resolve to a unique name (so a static schema cannot collide/overwrite across certificates).
+export const buildDestinationCertificateNameSchema = (options: {
+ naming: { NAME_PATTERN: RE2; FORBIDDEN_CHARACTERS: string };
+ message: string;
+ requireCertificateIdentifier?: boolean;
+}) =>
+ z
+ .string()
+ .trim()
+ .min(1, "Certificate name schema is required")
+ .refine(
+ (schema) => {
+ const testName = buildCertificateNameSchemaTestName(schema);
+ const hasForbiddenChars = options.naming.FORBIDDEN_CHARACTERS.split("").some((char) => testName.includes(char));
+ const hasCertificateIdentifier =
+ !options.requireCertificateIdentifier ||
+ schema.includes("{{certificateId}}") ||
+ schema.includes("{{shortCertificateId}}");
+ return hasCertificateIdentifier && options.naming.NAME_PATTERN.test(testName) && !hasForbiddenChars;
+ },
+ { message: options.message }
+ );
+
// Schema for PKI sync options configuration
export const PkiSyncOptionsSchema = z.object({
canImportCertificates: z.boolean(),
diff --git a/docs/documentation/platform/pki/applications/certificate-syncs/kemp-loadmaster.mdx b/docs/documentation/platform/pki/applications/certificate-syncs/kemp-loadmaster.mdx
index 114551135c..73af4cc9d0 100644
--- a/docs/documentation/platform/pki/applications/certificate-syncs/kemp-loadmaster.mdx
+++ b/docs/documentation/platform/pki/applications/certificate-syncs/kemp-loadmaster.mdx
@@ -31,9 +31,8 @@ Deploy certificates to Progress Kemp LoadMaster load balancers via the RESTful A
4. Configure the **Sync Options**:
- **Enable Removal of Expired/Revoked Certificates**: Remove certificates from the destination if they are no longer active.
- - **Preserve Certificate on Renewal**: Reuse the existing certificate identifier when a certificate renews, preserving the name and any Virtual Service binding.
- - **Sync Certificate Authorities**: When enabled, each certificate's chain (intermediate CA certificates) is uploaded into the LoadMaster's Intermediate Certs store so it can build the complete chain it presents to clients. When disabled, only the leaf certificates are managed.
- - **CA Certificate Name Schema**: Shown when Sync Certificate Authorities is enabled. Controls how CA certificates are named in the Intermediate Certs store using the `{{fingerprint}}` and `{{commonName}}` placeholders. Defaults to `Infisical-ca-{{fingerprint}}`.
+ - **Preserve Certificate on Renewal**: When a certificate is renewed, keep using the original certificate's identifier on the LoadMaster instead of generating a new name from the schema. This preserves the entry and any Virtual Service binding, and matters when your name schema is certificate-specific (for example it includes `{{certificateId}}`, which changes on renewal).
+ - **CA Certificate Name Schema**: Controls how each certificate's chain (intermediate CA certificates) is named in the LoadMaster's Intermediate Certs store, using the `{{fingerprint}}` and `{{commonName}}` placeholders. Defaults to `Infisical-ca-{{fingerprint}}`.
- **Certificate Name Schema**: Customize certificate identifiers using placeholders such as `{{certificateId}}`, `{{commonName}}`, `{{profileId}}`, and `{{applicationId}}`. Must include `{{certificateId}}` or `{{shortCertificateId}}`. Defaults to `Infisical-{{certificateId}}`. See [Certificate Name Schema](/documentation/platform/pki/applications/certificate-syncs/overview#certificate-name-schema) for the full placeholder reference.
- **Auto-Sync Enabled**: Automatically sync certificates when changes occur.
@@ -128,20 +127,19 @@ The Kemp LoadMaster Certificate Sync provides:
## How It Works
-When syncing certificates, Infisical performs the following steps on the LoadMaster via the RESTful API:
+Infisical automatically keeps your LoadMaster certificates in sync:
-1. Lists the existing certificate identifiers on the LoadMaster.
-2. When **Sync Certificate Authorities** is enabled, uploads each certificate's chain (intermediate CA certificates) into the LoadMaster's dedicated intermediate certificate store, which is how the LoadMaster builds the complete chain it presents to clients. The chain is also included in the leaf import as a fallback.
-3. For each certificate, imports a PEM bundle (certificate, chain, and private key) under its identifier, replacing the entry if the identifier already exists.
-4. If a Virtual Service is configured, reconciles its bound certificate list so the managed certificates are bound while any certificates the sync does not manage are left in place.
-5. If removal is enabled, unbinds certificates that are no longer active in Infisical from the Virtual Service and then deletes them from the certificate store.
+- Uploads certificates, with their chains and private keys, to the LoadMaster.
+- Uploads the intermediate CA certificates into the LoadMaster's Intermediate Certs store so clients receive the complete trust chain.
+- Optionally binds them to a Virtual Service for HTTPS termination.
+- Optionally removes certificates that are no longer active in Infisical.
## Certificate Renewal Behavior
When a certificate is renewed in Infisical, the behavior depends on the **Preserve Certificate on Renewal** option:
-- **Preserve enabled (default)**: The existing certificate identifier is reused and its content replaced with the renewed certificate. The identifier and any Virtual Service binding are preserved. This is ideal for production environments.
-- **Preserve disabled**: A new certificate identifier is created for the renewed certificate. The original certificate remains on the LoadMaster until it is revoked or removed.
+- **Preserve enabled (default)**: The renewed certificate reuses the original certificate's identifier and replaces that entry in place, so the name and any Virtual Service binding are preserved. This matters when your name schema is certificate-specific (for example it includes `{{certificateId}}`, which would otherwise resolve to a new name on renewal). Ideal for production environments.
+- **Preserve disabled**: The renewed certificate is imported under a newly generated identifier, and the original certificate remains on the LoadMaster until it is revoked or removed.
## Removing Certificates
diff --git a/docs/documentation/platform/pki/applications/certificate-syncs/netscaler.mdx b/docs/documentation/platform/pki/applications/certificate-syncs/netscaler.mdx
index 572c8189d6..afdd64a09e 100644
--- a/docs/documentation/platform/pki/applications/certificate-syncs/netscaler.mdx
+++ b/docs/documentation/platform/pki/applications/certificate-syncs/netscaler.mdx
@@ -128,16 +128,13 @@ The NetScaler Certificate Sync provides:
## How It Works
-When syncing certificates, Infisical performs the following steps on the NetScaler appliance via the NITRO REST API:
-
-1. Logs in to the NetScaler NITRO API using the configured credentials.
-2. For each certificate:
- - Uploads the certificate file (`.cer`) to `/nsconfig/ssl/`.
- - Uploads the private key file (`.key`) to `/nsconfig/ssl/`.
- - Creates or updates an `sslcertkey` object linking the cert and key.
- - If a vServer is configured, binds the certkey to the SSL virtual server.
-3. Saves the running configuration to persist changes across reboots.
-4. Logs out of the session.
+Infisical automatically keeps your NetScaler certificates in sync:
+
+- Uploads certificates, with their private keys, to the NetScaler appliance.
+- Optionally binds them to an SSL virtual server for HTTPS termination.
+- Optionally removes certificates that are no longer active in Infisical.
+
+Changes are saved to the running configuration so they persist across reboots.
## Certificate Renewal Behavior
diff --git a/docs/documentation/platform/pki/applications/certificate-syncs/nutanix-prism-central.mdx b/docs/documentation/platform/pki/applications/certificate-syncs/nutanix-prism-central.mdx
index 7289550ae4..d56a5fa7b5 100644
--- a/docs/documentation/platform/pki/applications/certificate-syncs/nutanix-prism-central.mdx
+++ b/docs/documentation/platform/pki/applications/certificate-syncs/nutanix-prism-central.mdx
@@ -107,13 +107,11 @@ Before setting up the sync, gather the following from your Nutanix environment:
## How It Works
-When a sync runs, Infisical calls the Nutanix Clustermgmt API v4 to replace the SSL certificate on the selected cluster:
+Infisical automatically keeps your Nutanix Prism Central cluster certificate in sync:
-1. Connects to Prism Central using the configured credentials (Basic Auth or API Key).
-2. Takes the certificate associated with the sync.
-3. Configures the certificate and private key onto the Nutanix cluster.
+- Replaces the cluster's SSL certificate and private key whenever the certificate changes in Infisical.
-After a few seconds, the Nutanix cluster will use the new certificate, no restart is required.
+The cluster begins using the new certificate within a few seconds, with no restart required.
<Note>
Each Nutanix Prism Central sync targets a single cluster. To update multiple clusters, create one sync per cluster.
diff --git a/docs/integrations/app-connections/adcs.mdx b/docs/integrations/app-connections/adcs.mdx
index 299b26d7c4..07f2229842 100644
--- a/docs/integrations/app-connections/adcs.mdx
+++ b/docs/integrations/app-connections/adcs.mdx
@@ -18,7 +18,7 @@ Connect Infisical to Microsoft Active Directory Certificate Services (AD CS) thr
<Steps>
<Step title="Navigate to App Connections">
- Navigate to the **App Connections** tab on the **Organization Settings** page.
+ In Certificate Manager, navigate to the **App Connections** tab on the **Settings** page.
![App Connections Tab](/images/app-connections/general/add-connection.png)
</Step>
<Step title="Add Connection">
diff --git a/docs/integrations/app-connections/azure-adcs.mdx b/docs/integrations/app-connections/azure-adcs.mdx
index 7bc1741353..8d816e1a9e 100644
--- a/docs/integrations/app-connections/azure-adcs.mdx
+++ b/docs/integrations/app-connections/azure-adcs.mdx
@@ -16,7 +16,7 @@ Connect Infisical to Microsoft Active Directory Certificate Services (ADCS) for
<Steps>
<Step title="Navigate to App Connections">
- Navigate to the **App Connections** tab on the **Organization Settings** page.
+ In Certificate Manager, navigate to the **App Connections** tab on the **Settings** page.
![App Connections Tab](/images/app-connections/general/add-connection.png)
</Step>
<Step title="Add Connection">
diff --git a/docs/integrations/app-connections/digicert.mdx b/docs/integrations/app-connections/digicert.mdx
index b249c5974b..8b18fef60d 100644
--- a/docs/integrations/app-connections/digicert.mdx
+++ b/docs/integrations/app-connections/digicert.mdx
@@ -47,7 +47,7 @@ Infisical supports connecting to [DigiCert CertCentral](https://dev.digicert.com
<Tab title="Infisical UI">
<Steps>
<Step title="Navigate to App Connections">
- In your Infisical dashboard, go to **Organization Settings** → **App Connections**.
+ In Certificate Manager, go to **Settings** → **App Connections**.
![App Connections Tab](/images/app-connections/general/add-connection.png)
</Step>
diff --git a/docs/integrations/app-connections/f5-big-ip.mdx b/docs/integrations/app-connections/f5-big-ip.mdx
index 31acc46b6c..6b15e61bbf 100644
--- a/docs/integrations/app-connections/f5-big-ip.mdx
+++ b/docs/integrations/app-connections/f5-big-ip.mdx
@@ -29,7 +29,7 @@ Infisical supports connecting to F5 BIG-IP LTM appliances via the iControl REST
</Note>
</Step>
<Step title="Navigate to App Connections">
- In the Infisical dashboard, navigate to **Organization Settings** > **App Connections** and click **Add Connection**.
+ In Certificate Manager, navigate to **Settings** > **App Connections** and click **Add Connection**.
</Step>
<Step title="Select F5 BIG-IP">
Select the **F5 BIG-IP** option from the list of available connections.
diff --git a/docs/integrations/app-connections/kemp-loadmaster.mdx b/docs/integrations/app-connections/kemp-loadmaster.mdx
index 6ad2c6ae16..8a2644d810 100644
--- a/docs/integrations/app-connections/kemp-loadmaster.mdx
+++ b/docs/integrations/app-connections/kemp-loadmaster.mdx
@@ -26,7 +26,7 @@ Infisical supports connecting to Progress Kemp LoadMaster load balancers using b
</Note>
</Step>
<Step title="Navigate to App Connections">
- In the Infisical dashboard, navigate to **Organization Settings > App Connections** and click **Add Connection**.
+ In Certificate Manager, navigate to **Settings > App Connections** and click **Add Connection**.
</Step>
<Step title="Select Kemp LoadMaster">
Select the **Kemp LoadMaster** option from the list of available connections.
diff --git a/docs/integrations/app-connections/netscaler.mdx b/docs/integrations/app-connections/netscaler.mdx
index 1b2ab998c2..757eb0a1b6 100644
--- a/docs/integrations/app-connections/netscaler.mdx
+++ b/docs/integrations/app-connections/netscaler.mdx
@@ -27,7 +27,7 @@ Infisical supports connecting to Citrix NetScaler (ADC) appliances using basic a
</Note>
</Step>
<Step title="Navigate to App Connections">
- In the Infisical dashboard, navigate to **Organization Settings** > **App Connections** and click **Add Connection**.
+ In Certificate Manager, navigate to **Settings** > **App Connections** and click **Add Connection**.
![App Connections Tab](/images/app-connections/general/add-connection.png)
</Step>
diff --git a/docs/integrations/app-connections/nutanix-prism-central.mdx b/docs/integrations/app-connections/nutanix-prism-central.mdx
index 176a20297f..e654769d6d 100644
--- a/docs/integrations/app-connections/nutanix-prism-central.mdx
+++ b/docs/integrations/app-connections/nutanix-prism-central.mdx
@@ -28,7 +28,7 @@ Infisical supports connecting to Nutanix Prism Central using either Basic Auth c
</Warning>
</Step>
<Step title="Navigate to App Connections">
- In the Infisical dashboard, navigate to **Organization Settings** > **App Connections** and click **Add Connection**.
+ In Certificate Manager, navigate to **Settings** > **App Connections** and click **Add Connection**.
![App Connections Tab](/images/app-connections/general/add-connection.png)
</Step>
diff --git a/docs/integrations/app-connections/venafi-tpp.mdx b/docs/integrations/app-connections/venafi-tpp.mdx
index 8acc5560e7..e526c8e291 100644
--- a/docs/integrations/app-connections/venafi-tpp.mdx
+++ b/docs/integrations/app-connections/venafi-tpp.mdx
@@ -21,7 +21,7 @@ Connect Infisical to a self-hosted Venafi Trust Protection Platform (TPP) instan
<Steps>
<Step title="Navigate to App Connections">
- Navigate to the **App Connections** tab on the **Organization Settings** page.
+ In Certificate Manager, navigate to the **App Connections** tab on the **Settings** page.
![App Connections Tab](/images/app-connections/general/add-connection.png)
</Step>
<Step title="Add Connection">
diff --git a/docs/integrations/app-connections/venafi.mdx b/docs/integrations/app-connections/venafi.mdx
index c464066957..9baf10a7a3 100644
--- a/docs/integrations/app-connections/venafi.mdx
+++ b/docs/integrations/app-connections/venafi.mdx
@@ -14,7 +14,7 @@ Connect Infisical to Venafi TLS Protect Cloud to use Venafi as an external CA fo
<Steps>
<Step title="Navigate to App Connections">
- Navigate to the **App Connections** tab on the **Organization Settings** page.
+ In Certificate Manager, navigate to the **App Connections** tab on the **Settings** page.
![App Connections Tab](/images/app-connections/general/add-connection.png)
</Step>
<Step title="Add Connection">
diff --git a/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx b/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx
index 3db4510acd..b570c44a36 100644
--- a/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx
+++ b/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx
@@ -112,7 +112,6 @@ export const CreatePkiSyncForm = ({
includePrivateKey: true
}),
...(destination === PkiSync.KempLoadMaster && {
- syncCaCertificates: true,
caCertificateNameSchema: KEMP_DEFAULT_CA_NAME_SCHEMA
}),
...((destination === PkiSync.Chef || destination === PkiSync.AwsSecretsManager) && {
diff --git a/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsx b/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsx
index 7d37355573..9f289acd20 100644
--- a/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsx
+++ b/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsx
@@ -461,17 +461,20 @@ export const PkiSyncOptionsFields = ({ destination, isUpdate }: Props) => {
content={
<>
<p>
- <strong>Only applies to certificate renewals:</strong> controls what
- happens on the LoadMaster when Infisical renews a certificate.
+ <strong>Only applies to certificate renewals:</strong> controls the
+ identifier a renewed certificate uses on the LoadMaster.
</p>
<p className="mt-4">
- When on, the renewed certificate replaces the existing one under the same
- identifier, so any Virtual Service binding keeps working without extra
- setup.
+ When on, the renewed certificate keeps the original certificate&apos;s
+ identifier and replaces that entry in place, so any Virtual Service
+ binding keeps working. This matters when your name schema is
+ certificate-specific (for example it includes{" "}
+ <code>{"{{certificateId}}"}</code>), which would otherwise resolve to a
+ new name on renewal.
</p>
<p className="mt-4">
- When off, the renewed certificate is imported under a new identifier and
- the original stays on the LoadMaster.
+ When off, the renewed certificate is imported under a newly generated
+ identifier and the original stays on the LoadMaster.
</p>
</>
}
@@ -486,46 +489,6 @@ export const PkiSyncOptionsFields = ({ destination, isUpdate }: Props) => {
)}
{currentDestination === PkiSync.KempLoadMaster && (
- <Controller
- control={control}
- name="syncOptions.syncCaCertificates"
- render={({ field: { value, onChange }, fieldState: { error } }) => (
- <FormControl isError={Boolean(error)} errorText={error?.message}>
- <Switch
- className="bg-mineshaft-400/80 shadow-inner data-[state=checked]:bg-green/80"
- id="sync-ca-certificates"
- thumbClassName="bg-mineshaft-800"
- onCheckedChange={onChange}
- isChecked={value}
- >
- <p>
- Sync Certificate Authorities{" "}
- <Tooltip
- className="max-w-md"
- content={
- <>
- <p>
- When on, each certificate&apos;s chain (intermediate CA certificates) is
- uploaded into the LoadMaster&apos;s dedicated Intermediate Certs store so
- it can build the complete chain it presents to clients.
- </p>
- <p className="mt-4">
- When off, only the leaf certificates are managed and no CA certificates
- are pushed to the LoadMaster.
- </p>
- </>
- }
- >
- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />
- </Tooltip>
- </p>
- </Switch>
- </FormControl>
- )}
- />
- )}
-
- {currentDestination === PkiSync.KempLoadMaster && watch("syncOptions.syncCaCertificates") && (
<Controller
control={control}
name="syncOptions.caCertificateNameSchema"
@@ -535,8 +498,8 @@ export const PkiSyncOptionsFields = ({ destination, isUpdate }: Props) => {
tooltipText={
<div className="flex flex-col gap-3">
<span>
- When Certificate Authorities are synced, this schema names each CA
- (intermediate) certificate in the LoadMaster&apos;s Intermediate Certs store.
+ This schema names each CA (intermediate) certificate that Infisical pushes into
+ the LoadMaster&apos;s Intermediate Certs store.
</span>
<div className="flex flex-col">
diff --git a/frontend/src/components/pki-syncs/forms/schemas/kemp-loadmaster-pki-sync-destination-schema.ts b/frontend/src/components/pki-syncs/forms/schemas/kemp-loadmaster-pki-sync-destination-schema.ts
index 6895143cc7..5f88f181af 100644
--- a/frontend/src/components/pki-syncs/forms/schemas/kemp-loadmaster-pki-sync-destination-schema.ts
+++ b/frontend/src/components/pki-syncs/forms/schemas/kemp-loadmaster-pki-sync-destination-schema.ts
@@ -10,7 +10,6 @@ const KempLoadMasterSyncOptionsSchema = z.object({
canRemoveCertificates: z.boolean().default(true),
includeRootCa: z.boolean().default(false),
preserveItemOnRenewal: z.boolean().default(true),
- syncCaCertificates: z.boolean().default(true),
caCertificateNameSchema: z
.string()
.trim()
diff --git a/frontend/src/hooks/api/pkiSyncs/types/index.ts b/frontend/src/hooks/api/pkiSyncs/types/index.ts
index 2f57cd59eb..9dc3753ae7 100644
--- a/frontend/src/hooks/api/pkiSyncs/types/index.ts
+++ b/frontend/src/hooks/api/pkiSyncs/types/index.ts
@@ -60,7 +60,6 @@ type TCreatePkiSyncDTOBase = {
updateExistingCertificates?: boolean;
preserveSecretOnRenewal?: boolean;
includeRootCa?: boolean;
- syncCaCertificates?: boolean;
caCertificateNameSchema?: string;
exportFormat?: PkiSyncExportFormat;
includePrivateKey?: boolean;