Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Fixes
Carlos Monastyrski87a473291639
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex e8b6dec81d..18a195e8d2 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -2902,6 +2902,14 @@ export const AppConnections = {connectionId: `The ID of the ${APP_CONNECTION_NAME_MAP[app]} Connection to rotate credentials for.`}),CREDENTIALS: {+ PALO_ALTO_NETWORKS: {+ hostname: "The IP address or hostname of the management interface of the firewall or Panorama.",+ port: "The HTTPS port of the management interface. Defaults to 443.",+ username: "The username of the PAN-OS administrator to connect with.",+ password: "The password of the PAN-OS administrator.",+ sslRejectUnauthorized: "Whether to reject the management interface's TLS certificate if it isn't trusted.",+ sslCertificate: "The PEM-encoded CA certificate to trust for the management interface's TLS certificate."+ },AUTH0_CONNECTION: {domain: "The domain of the Auth0 instance to connect to.",clientId: "Your Auth0 application's Client ID.",@@ -4575,6 +4583,16 @@ export const AGENT_VAULT = {}};+export const PALO_ALTO_NETWORKS_PKI_SYNC_DESTINATION_CONFIG = {+ template:+ "The Panorama template to store certificates in. Required when the connection points to a Panorama, and not allowed for a firewall.",+ pushToDevices:+ "Whether to push every template stack that contains the template to its firewalls after a commit. Applies to Panorama only.",+ sslTlsServiceProfileName: "The name of the SSL/TLS service profile to point at the synced certificate.",+ sslTlsServiceProfileVsys:+ "The virtual system the SSL/TLS service profile belongs to. Leave it out for a shared profile."+};+export const PKI_SYNC_FILTERS = {filters:"Which of the Application's certificates this sync holds. A certificate must match every field that is set, and a sync with no filters holds nothing.",diff --git a/backend/src/services/app-connection/palo-alto-networks/palo-alto-networks-connection-schemas.ts b/backend/src/services/app-connection/palo-alto-networks/palo-alto-networks-connection-schemas.tsindex 1e0c0bcb9b..d887ceb46c 100644--- a/backend/src/services/app-connection/palo-alto-networks/palo-alto-networks-connection-schemas.ts+++ b/backend/src/services/app-connection/palo-alto-networks/palo-alto-networks-connection-schemas.ts@@ -19,17 +19,31 @@ export const PaloAltoNetworksConnectionBasicAuthCredentialsSchema = z.object({.max(512, "Hostname cannot exceed 512 characters").refine((val) => !val.includes("/") && !val.includes("@") && !val.includes("?"), {message: "Hostname must not contain /, @, or ? characters"- }),- port: z.number().int().min(1).max(65535).optional(),- username: z.string().trim().min(1, "Username is required").max(256, "Username cannot exceed 256 characters"),- password: z.string().min(1, "Password is required").max(512, "Password cannot exceed 512 characters"),- sslRejectUnauthorized: z.boolean().optional(),+ })+ .describe(AppConnections.CREDENTIALS.PALO_ALTO_NETWORKS.hostname),+ port: z.number().int().min(1).max(65535).optional().describe(AppConnections.CREDENTIALS.PALO_ALTO_NETWORKS.port),+ username: z+ .string()+ .trim()+ .min(1, "Username is required")+ .max(256, "Username cannot exceed 256 characters")+ .describe(AppConnections.CREDENTIALS.PALO_ALTO_NETWORKS.username),+ password: z+ .string()+ .min(1, "Password is required")+ .max(512, "Password cannot exceed 512 characters")+ .describe(AppConnections.CREDENTIALS.PALO_ALTO_NETWORKS.password),+ sslRejectUnauthorized: z+ .boolean()+ .optional()+ .describe(AppConnections.CREDENTIALS.PALO_ALTO_NETWORKS.sslRejectUnauthorized),sslCertificate: z.string().trim().max(16384, "SSL certificate cannot exceed 16384 characters").transform((value) => value || undefined).optional()+ .describe(AppConnections.CREDENTIALS.PALO_ALTO_NETWORKS.sslCertificate)});const BasePaloAltoNetworksConnectionSchema = BaseAppConnectionSchema.extend({diff --git a/backend/src/services/certificate-sync/certificate-sync-dal.ts b/backend/src/services/certificate-sync/certificate-sync-dal.tsindex 4318bf6f3d..1ebdf26b5a 100644--- a/backend/src/services/certificate-sync/certificate-sync-dal.ts+++ b/backend/src/services/certificate-sync/certificate-sync-dal.ts@@ -202,27 +202,6 @@ export const certificateSyncDALFactory = (db: TDbClient) => {}};- const updateSyncStatusIfIn = async (- {- pkiSyncId,- certificateIds,- currentStatuses,- status,- message- }: { pkiSyncId: string; certificateIds: string[]; currentStatuses: string[]; status: string; message: string },- tx?: Knex- ): Promise<void> => {- try {- await (tx || db)(TableName.CertificateSync)- .where({ pkiSyncId })- .whereIn("certificateId", certificateIds)- .whereIn("syncStatus", currentStatuses)- .update({ syncStatus: status, lastSyncMessage: message, lastSyncedAt: new Date() });- } catch (error) {- throw new DatabaseError({ error, name: "UpdateSyncStatusIfIn" });- }- };-const updateSyncMetadata = async (pkiSyncId: string,certificateId: string,@@ -404,7 +383,6 @@ export const certificateSyncDALFactory = (db: TDbClient) => {updateSyncMetadata,clearSyncMetadataFlag,setSyncMetadataFlag,- updateSyncStatusIfIn,findWithDetails};};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.tsindex 79d0f90c92..2e89cba3f1 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@@ -63,7 +63,7 @@ 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 without {{certificateId}}, {{shortCertificateId}}, or {{commonName}} can be linked to only one certificate."+ "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."})});diff --git a/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-schemas.ts b/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-schemas.tsindex 7d0635bb0d..2ade551d2c 100644--- a/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-schemas.ts+++ b/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-schemas.ts@@ -115,7 +115,7 @@ export const LinuxServerPkiSyncOptionsSchema = z.object({},{message:- "Certificate name schema must resolve to a single file name of 1-200 characters using only letters, digits, dots (.), dashes (-), and underscores (_). Available placeholders: {{certificateId}}, {{shortCertificateId}}, {{profileId}}, {{applicationId}}, {{applicationName}}, {{commonName}}. A schema without {{certificateId}}, {{shortCertificateId}}, or {{commonName}} can be linked to only one certificate."+ "Certificate name schema must resolve to a single file name of 1-200 characters using only letters, digits, dots (.), dashes (-), and underscores (_). Available placeholders: {{certificateId}}, {{shortCertificateId}}, {{profileId}}, {{applicationId}}, {{applicationName}}, {{commonName}}. A schema with no placeholder can be linked to only one certificate."})});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.tsindex 341fc65905..db3b2b89d8 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@@ -22,7 +22,7 @@ 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 without {{certificateId}}, {{shortCertificateId}}, or {{commonName}} can be linked to only one certificate."+ "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."})});diff --git a/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-fns.test.ts b/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-fns.test.tsnew file mode 100644index 0000000000..787ceec2aa--- /dev/null+++ b/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-fns.test.ts@@ -0,0 +1,16 @@+import { buildManagedCertNamePattern } from "./palo-alto-networks-pki-sync-fns";++const SHORT_ID = "3hFkQ9xZr2mVw8LpT0aBcD";++describe("Palo Alto Networks buildManagedCertNamePattern (orphan cleanup detection)", () => {+ test("defaults to the INF-{{shortCertificateId}} schema", () => {+ const pattern = buildManagedCertNamePattern(undefined);+ expect(pattern.test(`INF-${SHORT_ID}`)).toBe(true);+ expect(pattern.test("mgmt-cert")).toBe(false);+ });++ test("never treats the imported CA chain objects as managed leaf certificates", () => {+ const pattern = buildManagedCertNamePattern(undefined);+ expect(pattern.test("INF-CA-0123456789abcdef01234567")).toBe(false);+ });+});diff --git a/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-fns.ts b/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-fns.tsindex 405db14734..ffab07022c 100644--- a/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-fns.ts+++ b/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-fns.ts@@ -21,9 +21,16 @@ import { TPaloAltoNetworksConnection } from "@app/services/app-connection/palo-aimport { TCertificateDALFactory } from "@app/services/certificate/certificate-dal";import { 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";-import { compileCertificateNameSchema } from "../pki-sync-certificate-name-fns";+import {+ buildManagedCertificateNameRegexSource,+ certificateNameSchemaHasFreeTextPlaceholder,+ compileCertificateNameSchema,+ SHORT_UUID_NAME_REGEX_FRAGMENT,+ UUID_NAME_REGEX_FRAGMENT+} from "../pki-sync-certificate-name-fns";import { PkiSync } from "../pki-sync-enums";import { PkiSyncError } from "../pki-sync-errors";import { TPkiSyncWithCredentials } from "../pki-sync-types";@@ -39,6 +46,7 @@ type TPaloAltoNetworksPkiSyncFactoryDeps = {TCertificateSyncDALFactory,| "removeCertificates"| "findByPkiSyncId"+ | "bulkUpdateSyncStatus"| "findExternalIdentifiersInUse"| "claimExternalIdentifier"| "setSyncMetadataFlag"@@ -278,6 +286,18 @@ const commitAndPush = async (}};+export const buildManagedCertNamePattern = (certificateNameSchema: string | undefined): RE2 => {+ const pattern = buildManagedCertificateNameRegexSource(+ certificateNameSchema ?? PALO_ALTO_NETWORKS_PKI_SYNC_LIST_OPTION.defaultCertificateNameSchema,+ {+ uuid: UUID_NAME_REGEX_FRAGMENT,+ shortUuid: SHORT_UUID_NAME_REGEX_FRAGMENT,+ freeText: "[a-zA-Z0-9_-]*"+ }+ );+ return new RE2(`^${pattern}$`);+};+type TPlannedUpload = TCertificateMap[string] & {mapKey: string;name: string;@@ -536,6 +556,7 @@ export const paloAltoNetworksPkiSyncFactory = ({activeNames: Set<string>;deployPending: TDeployPendingMarker;}) => {+ const { certificateNameSchema } = pkiSync.syncOptions as TPaloAltoNetworksPkiSyncOptions;const failedRemovals: TSyncFailure[] = [];let removedCount = 0;@@ -548,6 +569,19 @@ export const paloAltoNetworksPkiSyncFactory = ({));+ if (!certificateNameSchemaHasFreeTextPlaceholder(certificateNameSchema)) {+ const managedPattern = buildManagedCertNamePattern(certificateNameSchema);+ existingCertificates.forEach((_, name) => {+ if (+ managedPattern.test(name) &&+ !activeNames.has(name) &&+ !name.startsWith(PALO_ALTO_NETWORKS_CA_CERTIFICATE_PREFIX)+ ) {+ candidates.add(name);+ }+ });+ }+const ownedByOtherSync = await findNamesOwnedByOtherSyncs(pkiSync, [...candidates]);for (const name of candidates) {@@ -598,6 +632,18 @@ export const paloAltoNetworksPkiSyncFactory = ({: []);+ const markRunFailed = async (error: unknown) => {+ const message = error instanceof Error ? error.message : "The sync did not complete.";+ await certificateSyncDAL.bulkUpdateSyncStatus(+ certificateIds.map((certificateId) => ({+ pkiSyncId: pkiSync.id,+ certificateId,+ status: CertificateSyncStatus.Failed,+ message+ }))+ );+ };+return withClient(pkiSync, async (client, panorama, config) => {const [existingCertificates, profileVsysCertificates, profileCertificate] = await Promise.all([listCertificates(client, config),@@ -691,6 +737,9 @@ export const paloAltoNetworksPkiSyncFactory = ({skippedCertificates: skippedCertificates.length ? skippedCertificates : undefined}};+ }).catch(async (error: unknown) => {+ await markRunFailed(error);+ throw error;});};diff --git a/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-schemas.ts b/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-schemas.tsindex 5873c8fd77..41993a8bd6 100644--- a/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-schemas.ts+++ b/backend/src/services/pki-sync/palo-alto-networks/palo-alto-networks-pki-sync-schemas.ts@@ -1,5 +1,7 @@+import RE2 from "re2";import { z } from "zod";+import { PALO_ALTO_NETWORKS_PKI_SYNC_DESTINATION_CONFIG } from "@app/lib/api-docs";import { openApiHidden } from "@app/server/lib/schemas";import { PanOsObjectNameSchema } from "@app/services/app-connection/palo-alto-networks/palo-alto-networks-connection-schemas";import { pkiDescriptionSchema } from "@app/services/certificate-common/certificate-constants";@@ -15,20 +17,32 @@ import {import { PALO_ALTO_NETWORKS_NAMING } from "./palo-alto-networks-pki-sync-constants";export const PaloAltoNetworksPkiSyncConfigSchema = z.object({- template: PanOsObjectNameSchema("Template").optional(),- pushToDevices: z.boolean().default(true)+ template: PanOsObjectNameSchema("Template")+ .optional()+ .describe(PALO_ALTO_NETWORKS_PKI_SYNC_DESTINATION_CONFIG.template),+ pushToDevices: z.boolean().default(true).describe(PALO_ALTO_NETWORKS_PKI_SYNC_DESTINATION_CONFIG.pushToDevices)});export const PaloAltoNetworksSslTlsProfilePkiSyncConfigSchema = PaloAltoNetworksPkiSyncConfigSchema.extend({- sslTlsServiceProfileName: PanOsObjectNameSchema("SSL/TLS service profile"),- sslTlsServiceProfileVsys: PanOsObjectNameSchema("Virtual system").optional()+ sslTlsServiceProfileName: PanOsObjectNameSchema("SSL/TLS service profile").describe(+ PALO_ALTO_NETWORKS_PKI_SYNC_DESTINATION_CONFIG.sslTlsServiceProfileName+ ),+ sslTlsServiceProfileVsys: PanOsObjectNameSchema("Virtual system")+ .optional()+ .describe(PALO_ALTO_NETWORKS_PKI_SYNC_DESTINATION_CONFIG.sslTlsServiceProfileVsys)});+const ANY_NAME_PLACEHOLDER = new RE2("\\{\\{\\w+\\}\\}");+const CERTIFICATE_NAME_PLACEHOLDER = new RE2("\\{\\{(certificateId|shortCertificateId|commonName)\\}\\}");+export const PaloAltoNetworksPkiSyncOptionsSchema = BasePkiSyncOptionsSchema.extend({certificateNameSchema: buildDestinationCertificateNameSchema({naming: PALO_ALTO_NETWORKS_NAMING,message:- "Certificate name schema must result in names that contain only alphanumeric characters, hyphens (-), and underscores (_) and be 1-31 characters long for Palo Alto Networks. Use {{shortCertificateId}} rather than {{certificateId}} to stay within the limit. Available placeholders: {{certificateId}}, {{shortCertificateId}}, {{profileId}}, {{applicationId}}, {{applicationName}}, {{commonName}}. A schema without {{certificateId}}, {{shortCertificateId}}, or {{commonName}} can be linked to only one certificate."+ "Certificate name schema must result in names that contain only alphanumeric characters, hyphens (-), and underscores (_) and be 1-31 characters long for Palo Alto Networks. Use {{shortCertificateId}} rather than {{certificateId}} to stay within the limit. Available placeholders: {{certificateId}}, {{shortCertificateId}}, {{profileId}}, {{applicationId}}, {{applicationName}}, {{commonName}}. A schema with no placeholder can be linked to only one certificate."+ }).refine((schema) => !schema || !ANY_NAME_PLACEHOLDER.test(schema) || CERTIFICATE_NAME_PLACEHOLDER.test(schema), {+ message:+ "Certificate name schema must include {{shortCertificateId}} or {{commonName}} so each certificate gets its own name, or use no placeholder for a single certificate."})});diff --git a/backend/src/services/pki-sync/pki-sync-certificate-name-fns.ts b/backend/src/services/pki-sync/pki-sync-certificate-name-fns.tsindex 6c0b097658..8a0721b907 100644--- a/backend/src/services/pki-sync/pki-sync-certificate-name-fns.ts+++ b/backend/src/services/pki-sync/pki-sync-certificate-name-fns.ts@@ -64,12 +64,11 @@ export const SHORT_UUID_NAME_REGEX_FRAGMENT = "[0-9A-Za-z]{22}";export const certificateNameSchemaHasFreeTextPlaceholder = (schema?: string): boolean =>Boolean(schema && (schema.includes("{{commonName}}") || schema.includes("{{applicationName}}")));-const CERTIFICATE_DISTINGUISHING_PLACEHOLDER_REGEX = new RE2(- "\\{\\{(certificateId|shortCertificateId|commonName)\\}\\}"+const ANY_PLACEHOLDER_REGEX = new RE2(+ "\\{\\{(certificateId|shortCertificateId|profileId|applicationId|applicationName|commonName)\\}\\}");-export const certificateNameSchemaAllowsMultipleCertificates = (schema?: string): boolean =>- Boolean(schema && CERTIFICATE_DISTINGUISHING_PLACEHOLDER_REGEX.test(schema));+ Boolean(schema && ANY_PLACEHOLDER_REGEX.test(schema));const PLACEHOLDER_OR_CHAR_REGEX = new RE2("\\{\\{(certificateId|shortCertificateId|profileId|applicationId|applicationName|commonName)\\}\\}|[\\s\\S]",diff --git a/backend/src/services/pki-sync/pki-sync-fns.test.ts b/backend/src/services/pki-sync/pki-sync-fns.test.tsindex 2dac896e5f..54dd162da1 100644--- a/backend/src/services/pki-sync/pki-sync-fns.test.ts+++ b/backend/src/services/pki-sync/pki-sync-fns.test.ts@@ -189,12 +189,12 @@ describe("assertPkiSyncCanHoldCertificateCount", () => {test("rejects a name schema with no placeholder once more than one certificate is held", () => {expect(() =>assertPkiSyncCanHoldCertificateCount(PkiSync.LinuxServer, { certificateNameSchema: "static" }, undefined, 2)- ).toThrow("gives every certificate the same name");+ ).toThrow("no placeholder");});test("rejects a sync with no name schema at all once more than one certificate is held", () => {expect(() => assertPkiSyncCanHoldCertificateCount(PkiSync.LinuxServer, undefined, undefined, 2)).toThrow(- "gives every certificate the same name"+ "no placeholder");});@@ -284,18 +284,6 @@ describe("getPkiSyncCertificateCap", () => {expect(getPkiSyncCertificateCap(PkiSync.LinuxServer, { certificateNameSchema: "static" }, {})).toBe(1);});- test("caps at 1 when the name schema only uses placeholders shared by every certificate", () => {- expect(- getPkiSyncCertificateCap(PkiSync.PaloAltoNetworks, { certificateNameSchema: "INF-{{applicationName}}" }, {})- ).toBe(1);- });-- test("no name cap when the name schema uses the common name", () => {- expect(- getPkiSyncCertificateCap(PkiSync.PaloAltoNetworks, { certificateNameSchema: "INF-{{commonName}}" }, {})- ).toBeUndefined();- });-test("caps at 1 when a host command names a single certificate", () => {expect(getPkiSyncCertificateCap(diff --git a/backend/src/services/pki-sync/pki-sync-fns.ts b/backend/src/services/pki-sync/pki-sync-fns.tsindex fb3f8d2f2f..7498d4111e 100644--- a/backend/src/services/pki-sync/pki-sync-fns.ts+++ b/backend/src/services/pki-sync/pki-sync-fns.ts@@ -774,7 +774,7 @@ const getPkiSyncCertificateCaps = (caps.push({cap: 1,reason: () =>- "This PKI sync's certificate name schema gives every certificate the same name, so it holds only one certificate. Add {{shortCertificateId}}, {{certificateId}}, or {{commonName}} to hold more."+ "This PKI sync's certificate name schema has no placeholder, so it holds only one certificate. Add {{certificateId}} or {{commonName}} to hold more."});}diff --git a/backend/src/services/pki-sync/pki-sync-queue.ts b/backend/src/services/pki-sync/pki-sync-queue.tsindex f559f63102..f7f4298162 100644--- a/backend/src/services/pki-sync/pki-sync-queue.ts+++ b/backend/src/services/pki-sync/pki-sync-queue.ts@@ -104,12 +104,6 @@ type PkiSyncActionJob = Job<TQueuePkiSyncSyncCertificatesByIdDTO | TQueuePkiSyncImportCertificatesByIdDTO | TQueuePkiSyncRemoveCertificatesByIdDTO>;-const NON_TERMINAL_CERTIFICATE_SYNC_STATUSES = new Set<string>([- CertificateSyncStatus.Pending,- CertificateSyncStatus.Running,- CertificateSyncStatus.Syncing-]);-const JITTER_MS = 10 * 1000;const HOST_SERIALISATION_LOCK_TTL_MS = 5 * 60 * 1000;@@ -255,7 +249,6 @@ export const pkiSyncQueueFactory = ({);let isSynced = false;- let runCertificateIds: string[] = [];let certSyncFailureCount = 0;let syncMessage: string | null = null;let partialFailure = false;@@ -285,7 +278,6 @@ export const pkiSyncQueueFactory = ({if (statusUpdates.length > 0) {await certificateSyncDAL.bulkUpdateSyncStatus(statusUpdates);- runCertificateIds = statusUpdates.map((update) => update.certificateId);}const syncResult = await PkiSyncFns.syncCertificates(pkiSyncWithCredentials, certificateMap, {@@ -386,13 +378,18 @@ export const pkiSyncQueueFactory = ({certSyncFailureCount = failedCertificateCount + (syncResult.failedRemovals ?? 0);const processedCertificateIds = new Set(Array.from(certificateMetadata.values()).map((meta) => meta.id));+ const nonTerminalStatuses = new Set<string>([+ CertificateSyncStatus.Pending,+ CertificateSyncStatus.Running,+ CertificateSyncStatus.Syncing+ ]);const trackedRecords = await certificateSyncDAL.findByPkiSyncId(pkiSync.id);const strandedCertificateIds = trackedRecords.filter((record) =>record.certificateId &&!processedCertificateIds.has(record.certificateId) &&- NON_TERMINAL_CERTIFICATE_SYNC_STATUSES.has(record.syncStatus ?? "")+ nonTerminalStatuses.has(record.syncStatus ?? "")).map((record) => record.certificateId).filter((id): id is string => typeof id === "string");@@ -495,16 +492,6 @@ export const pkiSyncQueueFactory = ({}});- if (!isSynced && isFinalAttempt && runCertificateIds.length > 0) {- await certificateSyncDAL.updateSyncStatusIfIn({- pkiSyncId: pkiSync.id,- certificateIds: runCertificateIds,- currentStatuses: [...NON_TERMINAL_CERTIFICATE_SYNC_STATUSES],- status: CertificateSyncStatus.Failed,- message: syncMessage ?? "The sync did not complete."- });- }-if (isSynced || isFinalAttempt) {if (!fullySynced) {let failureKind = PkiSyncFailureKind.Sync;diff --git a/backend/src/services/pki-sync/pki-sync-schemas.ts b/backend/src/services/pki-sync/pki-sync-schemas.tsindex 4b357b73d3..491803739b 100644--- a/backend/src/services/pki-sync/pki-sync-schemas.ts+++ b/backend/src/services/pki-sync/pki-sync-schemas.ts@@ -125,7 +125,7 @@ export const PkiSyncOptionsSchema = z.object({},{message:- "Certificate name schema may include the {{certificateId}}, {{shortCertificateId}}, {{profileId}}, {{applicationId}}, {{applicationName}}, and {{commonName}} placeholders. Only alphanumeric characters (a-z, A-Z, 0-9), dashes (-), underscores (_), and slashes (/) are allowed besides the placeholders. A schema without {{certificateId}}, {{shortCertificateId}}, or {{commonName}} can be linked to only one certificate."+ "Certificate name schema may include the {{certificateId}}, {{shortCertificateId}}, {{profileId}}, {{applicationId}}, {{applicationName}}, and {{commonName}} placeholders. Only alphanumeric characters (a-z, A-Z, 0-9), dashes (-), underscores (_), and slashes (/) are allowed besides the placeholders. A schema with no placeholder can be linked to only one certificate."})});diff --git a/backend/src/services/pki-sync/pki-sync-service.ts b/backend/src/services/pki-sync/pki-sync-service.tsindex bcc989d3a2..1afb93ed7b 100644--- a/backend/src/services/pki-sync/pki-sync-service.ts+++ b/backend/src/services/pki-sync/pki-sync-service.ts@@ -329,7 +329,7 @@ export const pkiSyncServiceFactory = ({);};- const $assertDestinationReachable = async ({+ const $assertTargetHostReachable = async ({destination,connection,destinationConfig@@ -338,10 +338,10 @@ export const pkiSyncServiceFactory = ({connection: { id: string; app: AppConnection };destinationConfig: Record<string, unknown> | null | undefined;}) => {- const isValidatedOnSave =- connection.app === AppConnection.PaloAltoNetworks ||- (connection.app === AppConnection.LDAP && Boolean(getPkiSyncTargetHost(destinationConfig)));- if (!isValidatedOnSave) return;+ if (connection.app !== AppConnection.PaloAltoNetworks) {+ if (connection.app !== AppConnection.LDAP) return;+ if (!getPkiSyncTargetHost(destinationConfig)) return;+ }await pkiSyncHealthCheckQueue.testTargetHostReachable({destination,@@ -751,7 +751,7 @@ export const pkiSyncServiceFactory = ({);}- await $assertDestinationReachable({ destination, connection, destinationConfig });+ await $assertTargetHostReachable({ destination, connection, destinationConfig });const encryptedCredentials =credentials?.exportPassword && !isBlankExportPassword(credentials.exportPassword)@@ -949,7 +949,7 @@ export const pkiSyncServiceFactory = ({}if (isConnectionChanging || isDestinationConfigChanging) {- await $assertDestinationReachable({+ await $assertTargetHostReachable({destination: pkiSync.destination,connection: isConnectionChanging? await resolveConnection()@@ -974,20 +974,14 @@ export const pkiSyncServiceFactory = ({resolveConnection});- const storedFilters = pkiSync.filters as TPkiSyncFilters | null;- const areFiltersChanging =- filters !== undefined && JSON.stringify(filters ?? null) !== JSON.stringify(storedFilters ?? null);-if (syncOptions || destinationConfig) {- if (!areFiltersChanging) {- const existingCount = (await certificateSyncDAL.findByPkiSyncId(id)).length;- assertPkiSyncCertificateCapsAllowCount(- pkiSync.destination,- effectiveSyncOptions,- effectiveDestinationConfig,- existingCount- );- }+ const existingCount = (await certificateSyncDAL.findByPkiSyncId(id)).length;+ assertPkiSyncCertificateCapsAllowCount(+ pkiSync.destination,+ effectiveSyncOptions,+ effectiveDestinationConfig,+ existingCount+ );assertFiltersCannotExceedCertificateCap(pkiSync.destination,effectiveSyncOptions,@@ -1040,6 +1034,10 @@ export const pkiSyncServiceFactory = ({return pkiSync as TPkiSync;}+ const storedFilters = pkiSync.filters as TPkiSyncFilters | null;+ const areFiltersChanging =+ filters !== undefined && JSON.stringify(filters ?? null) !== JSON.stringify(storedFilters ?? null);+if (areFiltersChanging) $assertSyncAcceptsFilters(pkiSync);if (!areFiltersChanging) {diff --git a/backend/src/services/pki-sync/windows-server/windows-server-pki-sync-schemas.ts b/backend/src/services/pki-sync/windows-server/windows-server-pki-sync-schemas.tsindex ff0c80f1e3..cb4868d409 100644--- a/backend/src/services/pki-sync/windows-server/windows-server-pki-sync-schemas.ts+++ b/backend/src/services/pki-sync/windows-server/windows-server-pki-sync-schemas.ts@@ -125,7 +125,7 @@ export const WindowsServerPkiSyncOptionsSchema = z.object({},{message:- "Certificate name schema must resolve to a single file name of 1-200 characters using only letters, digits, dots (.), dashes (-), and underscores (_). Available placeholders: {{certificateId}}, {{shortCertificateId}}, {{profileId}}, {{applicationId}}, {{applicationName}}, {{commonName}}. A schema without {{certificateId}}, {{shortCertificateId}}, or {{commonName}} can be linked to only one certificate."+ "Certificate name schema must resolve to a single file name of 1-200 characters using only letters, digits, dots (.), dashes (-), and underscores (_). Available placeholders: {{certificateId}}, {{shortCertificateId}}, {{profileId}}, {{applicationId}}, {{applicationName}}, {{commonName}}. A schema with no placeholder can be linked to only one certificate."})});diff --git a/docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdx b/docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdxindex fd6700e80d..9765d1c262 100644--- a/docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdx+++ b/docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdx@@ -51,7 +51,7 @@ Deploy certificates from Infisical to a directory on a Linux server over SSH. Fi- **Include Private Key**: For PEM, controls whether the private key is written alongside the certificate. The sync fails for a certificate whose key is not available, for example one issued from an external CSR.- **Include Root CA in Certificate Chain**: Include the root CA in the delivered chain. Leave it off when the consuming service only needs the intermediates.- **Enable Removal of Certificates**: Delete the delivered files from the server when a certificate is removed from the sync, revoked, or expired.- - **Certificate Name Schema**: The base file name, using placeholders such as `{{commonName}}`, `{{certificateId}}`, or `{{shortCertificateId}}`. The export format adds the extension. A schema without {{certificateId}}, {{shortCertificateId}}, or {{commonName}} can be linked to only one certificate.+ - **Certificate Name Schema**: The base file name, using placeholders such as `{{commonName}}`, `{{certificateId}}`, or `{{shortCertificateId}}`. The export format adds the extension. A schema with no placeholder can be linked to only one certificate.- **Auto-Sync Enabled**: Automatically sync certificates when changes occur.6. Configure the **Commands**, or leave them empty:diff --git a/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx b/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdxindex 8442521b5d..22178681bb 100644--- a/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx+++ b/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx@@ -59,7 +59,7 @@ Deploy certificates from Infisical to a directory on a Windows server over WinRM- **Include Private Key**: For PEM, controls whether the private key is written alongside the certificate. The sync fails for a certificate whose key is not available, for example one issued from an external CSR.- **Include Root CA in Certificate Chain**: Include the root CA in the delivered chain. Leave it off when the consuming service only needs the intermediates.- **Enable Removal of Certificates**: Delete the delivered files from the server when a certificate is removed from the sync, revoked, or expired.- - **Certificate Name Schema**: The base file name, using placeholders such as `{{commonName}}`, `{{certificateId}}`, or `{{shortCertificateId}}`. The export format adds the extension. A schema without {{certificateId}}, {{shortCertificateId}}, or {{commonName}} can be linked to only one certificate.+ - **Certificate Name Schema**: The base file name, using placeholders such as `{{commonName}}`, `{{certificateId}}`, or `{{shortCertificateId}}`. The export format adds the extension. A schema with no placeholder can be linked to only one certificate.- **Auto-Sync Enabled**: Automatically sync certificates when changes occur.6. Configure the **Commands**, or leave them empty:diff --git a/frontend/src/components/pki-syncs/forms/pki-sync-filter-fns.ts b/frontend/src/components/pki-syncs/forms/pki-sync-filter-fns.tsindex 03d6945af3..e78cea93e0 100644--- a/frontend/src/components/pki-syncs/forms/pki-sync-filter-fns.ts+++ b/frontend/src/components/pki-syncs/forms/pki-sync-filter-fns.ts@@ -48,7 +48,8 @@ export const buildOrderNameMap = (const GCP_MAX_CERTIFICATES_PER_MAP_ENTRY = 4;-const NAME_SCHEMA_PLACEHOLDER_PATTERN = /\{\{(certificateId|shortCertificateId|commonName)\}\}/;+const NAME_SCHEMA_PLACEHOLDER_PATTERN =+ /\{\{(certificateId|shortCertificateId|profileId|applicationId|applicationName|commonName)\}\}/;const COMMAND_VARIABLE_PATTERN = /\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g;diff --git a/frontend/src/components/pki-syncs/forms/schemas/palo-alto-networks-pki-sync-destination-schema.ts b/frontend/src/components/pki-syncs/forms/schemas/palo-alto-networks-pki-sync-destination-schema.tsindex c6e816fb49..cd2c4e655c 100644--- a/frontend/src/components/pki-syncs/forms/schemas/palo-alto-networks-pki-sync-destination-schema.ts+++ b/frontend/src/components/pki-syncs/forms/schemas/palo-alto-networks-pki-sync-destination-schema.ts@@ -57,7 +57,16 @@ const PaloAltoNetworksSyncOptionsSchema = z.object({},{message:- "Certificate name schema must be at most 31 characters once placeholders are filled in ({{shortCertificateId}} counts as 22). Outside placeholders, use only letters, numbers, hyphens (-), and underscores (_). A name without {{shortCertificateId}} or {{commonName}} can hold only one certificate."+ "Certificate name schema must be at most 31 characters once placeholders are filled in ({{shortCertificateId}} counts as 22). Outside placeholders, use only letters, numbers, hyphens (-), and underscores (_)."+ }+ )+ .refine(+ (val) =>+ !/\{\{\w+\}\}/.test(val) ||+ /\{\{(certificateId|shortCertificateId|commonName)\}\}/.test(val),+ {+ message:+ "Certificate name schema must include {{shortCertificateId}} or {{commonName}} so each certificate gets its own name, or use no placeholder for a single certificate."})});