Skip to content

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

PKI update certificate name schema and shorten certificateId

Carlos Monastyrski03b387a4e7e9
diff --git a/backend/src/services/pki-sync/aws-certificate-manager/aws-certificate-manager-pki-sync-schemas.ts b/backend/src/services/pki-sync/aws-certificate-manager/aws-certificate-manager-pki-sync-schemas.ts
index 1d6bfd5503..5d1255696b 100644
--- a/backend/src/services/pki-sync/aws-certificate-manager/aws-certificate-manager-pki-sync-schemas.ts
+++ b/backend/src/services/pki-sync/aws-certificate-manager/aws-certificate-manager-pki-sync-schemas.ts
@@ -25,7 +25,7 @@ const AwsCertificateManagerPkiSyncOptionsSchema = z.object({
if (!schema) return true;
// Validate that {{certificateId}} placeholder is present
- if (!schema.includes("{{certificateId}}")) {
+ if (!schema.includes("{{certificateId}}") && !schema.includes("{{shortCertificateId}}")) {
return false;
}
@@ -44,7 +44,7 @@ const AwsCertificateManagerPkiSyncOptionsSchema = z.object({
},
{
message:
- "Certificate name schema must include {{certificateId}} placeholder and result in names that contain only alphanumeric characters, spaces, hyphens, and underscores and be 1-256 characters long when compiled for AWS Certificate Manager. Available placeholders: {{certificateId}}, {{profileId}}, {{applicationId}}, {{commonName}}"
+ "Certificate name schema must include the {{certificateId}} or {{shortCertificateId}} placeholder and result in names that contain only alphanumeric characters, spaces, hyphens, and underscores and be 1-256 characters long when compiled for AWS Certificate Manager. Available placeholders: {{certificateId}}, {{shortCertificateId}}, {{profileId}}, {{applicationId}}, {{applicationName}}, {{commonName}}"
}
)
});
diff --git a/backend/src/services/pki-sync/aws-secrets-manager/aws-secrets-manager-pki-sync-schemas.ts b/backend/src/services/pki-sync/aws-secrets-manager/aws-secrets-manager-pki-sync-schemas.ts
index 4c634b4a87..d59abbc66f 100644
--- a/backend/src/services/pki-sync/aws-secrets-manager/aws-secrets-manager-pki-sync-schemas.ts
+++ b/backend/src/services/pki-sync/aws-secrets-manager/aws-secrets-manager-pki-sync-schemas.ts
@@ -33,7 +33,7 @@ const AwsSecretsManagerPkiSyncOptionsSchema = z.object({
(schema) => {
if (!schema) return true;
- if (!schema.includes("{{certificateId}}")) {
+ if (!schema.includes("{{certificateId}}") && !schema.includes("{{shortCertificateId}}")) {
return false;
}
@@ -52,7 +52,7 @@ const AwsSecretsManagerPkiSyncOptionsSchema = z.object({
},
{
message:
- "Certificate name schema must include {{certificateId}} placeholder and result in names that contain only alphanumeric characters, underscores, and hyphens and be 1-512 characters long for AWS Secrets Manager."
+ "Certificate name schema must include the {{certificateId}} or {{shortCertificateId}} placeholder and result in names that contain only alphanumeric characters, underscores, and hyphens and be 1-512 characters long for AWS Secrets Manager."
}
),
fieldMappings: AwsSecretsManagerFieldMappingsSchema.optional().default({
diff --git a/backend/src/services/pki-sync/azure-key-vault/azure-key-vault-pki-sync-schemas.ts b/backend/src/services/pki-sync/azure-key-vault/azure-key-vault-pki-sync-schemas.ts
index b50b6562b1..65dfca237b 100644
--- a/backend/src/services/pki-sync/azure-key-vault/azure-key-vault-pki-sync-schemas.ts
+++ b/backend/src/services/pki-sync/azure-key-vault/azure-key-vault-pki-sync-schemas.ts
@@ -24,7 +24,7 @@ export const AzureKeyVaultPkiSyncOptionsSchema = z.object({
(schema) => {
if (!schema) return true;
- if (!schema.includes("{{certificateId}}")) {
+ if (!schema.includes("{{certificateId}}") && !schema.includes("{{shortCertificateId}}")) {
return false;
}
@@ -38,7 +38,7 @@ export const AzureKeyVaultPkiSyncOptionsSchema = z.object({
},
{
message:
- "Certificate name schema must include the {{certificateId}} placeholder and result in names that contain only alphanumeric characters and hyphens (a-z, A-Z, 0-9, -) and be 1-127 characters long when compiled for Azure Key Vault. Available placeholders: {{certificateId}}, {{profileId}}, {{applicationId}}, {{commonName}}"
+ "Certificate name schema must include the {{certificateId}} or {{shortCertificateId}} placeholder and result in names that contain only alphanumeric characters and hyphens (a-z, A-Z, 0-9, -) and be 1-127 characters long when compiled for Azure Key Vault. Available placeholders: {{certificateId}}, {{shortCertificateId}}, {{profileId}}, {{applicationId}}, {{applicationName}}, {{commonName}}"
}
)
});
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 4951890547..e7ce55d3fa 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
@@ -40,7 +40,7 @@ const ChefPkiSyncOptionsSchema = z.object({
(schema) => {
if (!schema) return true;
- if (!schema.includes("{{certificateId}}")) {
+ if (!schema.includes("{{certificateId}}") && !schema.includes("{{shortCertificateId}}")) {
return false;
}
@@ -59,7 +59,7 @@ const ChefPkiSyncOptionsSchema = z.object({
},
{
message:
- "Certificate item name schema must include {{certificateId}} placeholder and result in names that contain only alphanumeric characters, underscores, and hyphens and be 1-255 characters long for Chef data bag items."
+ "Certificate item name schema must include the {{certificateId}} or {{shortCertificateId}} placeholder and result in names that contain only alphanumeric characters, underscores, and hyphens and be 1-255 characters long for Chef data bag items."
}
),
fieldMappings: ChefFieldMappingsSchema.optional().default({
diff --git a/backend/src/services/pki-sync/cloudflare-custom-certificate/cloudflare-custom-certificate-pki-sync-schemas.ts b/backend/src/services/pki-sync/cloudflare-custom-certificate/cloudflare-custom-certificate-pki-sync-schemas.ts
index 8d5850b935..f167380b1f 100644
--- a/backend/src/services/pki-sync/cloudflare-custom-certificate/cloudflare-custom-certificate-pki-sync-schemas.ts
+++ b/backend/src/services/pki-sync/cloudflare-custom-certificate/cloudflare-custom-certificate-pki-sync-schemas.ts
@@ -22,7 +22,7 @@ export const CloudflareCustomCertificatePkiSyncOptionsSchema = z.object({
(schema) => {
if (!schema) return true;
- if (!schema.includes("{{certificateId}}")) {
+ if (!schema.includes("{{certificateId}}") && !schema.includes("{{shortCertificateId}}")) {
return false;
}
@@ -36,7 +36,7 @@ export const CloudflareCustomCertificatePkiSyncOptionsSchema = z.object({
},
{
message:
- "Certificate name schema must include the {{certificateId}} placeholder and result in names that contain only alphanumeric characters, hyphens (-), and underscores (_) and be 1-255 characters long when compiled for Cloudflare. Available placeholders: {{certificateId}}, {{profileId}}, {{applicationId}}, {{commonName}}"
+ "Certificate name schema must include the {{certificateId}} or {{shortCertificateId}} placeholder and result in names that contain only alphanumeric characters, hyphens (-), and underscores (_) and be 1-255 characters long when compiled for Cloudflare. Available placeholders: {{certificateId}}, {{shortCertificateId}}, {{profileId}}, {{applicationId}}, {{applicationName}}, {{commonName}}"
}
)
});
diff --git a/backend/src/services/pki-sync/f5-big-ip/f5-big-ip-pki-sync-fns.ts b/backend/src/services/pki-sync/f5-big-ip/f5-big-ip-pki-sync-fns.ts
index bc910bfa04..3725f81957 100644
--- a/backend/src/services/pki-sync/f5-big-ip/f5-big-ip-pki-sync-fns.ts
+++ b/backend/src/services/pki-sync/f5-big-ip/f5-big-ip-pki-sync-fns.ts
@@ -20,7 +20,9 @@ import { TCertificateMap } from "@app/services/pki-sync/pki-sync-types";
import {
buildManagedCertificateNameRegexSource,
certificateNameSchemaHasFreeTextPlaceholder,
- compileCertificateNameSchema
+ 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";
@@ -98,11 +100,13 @@ export const buildManagedCertNamePattern = (certificateNameSchema: string | unde
return new RE2(`^${F5_BIG_IP_DEFAULT_CERT_NAME_PREFIX}[0-9a-f]{32}(-[a-zA-Z0-9]*)?$`);
}
- // {{certificateId}}, {{profileId}}, and {{applicationId}} resolve to dash-stripped UUIDs (32 hex chars).
- // {{commonName}} is arbitrary, so match any run of BIG-IP-safe characters.
+ // {{certificateId}}, {{profileId}}, and {{applicationId}} resolve to 32-char dash-stripped UUIDs;
+ // {{shortCertificateId}} resolves to a 22-char base62 string.
+ // {{commonName}} and {{applicationName}} are arbitrary, so match any run of BIG-IP-safe characters.
const pattern = buildManagedCertificateNameRegexSource(certificateNameSchema, {
- uuid: "[0-9a-f]{32}",
- commonName: "[a-zA-Z0-9._-]*"
+ uuid: UUID_NAME_REGEX_FRAGMENT,
+ shortUuid: SHORT_UUID_NAME_REGEX_FRAGMENT,
+ freeText: "[a-zA-Z0-9._-]*"
});
return new RE2(`^${pattern}$`);
@@ -841,6 +845,7 @@ export const f5BigIpPkiSyncFactory = ({
certificateId,
profileId: certData.profileId,
applicationId: pkiSync.applicationId,
+ applicationName: pkiSync.applicationName,
commonName: certData.commonName
},
PkiSync.F5BigIp
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 2ca7bb7ce2..a21aafb06d 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
@@ -64,7 +64,7 @@ export const F5BigIpPkiSyncOptionsSchema = z.object({
(schema) => {
if (!schema) return true;
- if (!schema.includes("{{certificateId}}")) {
+ if (!schema.includes("{{certificateId}}") && !schema.includes("{{shortCertificateId}}")) {
return false;
}
@@ -78,7 +78,7 @@ export const F5BigIpPkiSyncOptionsSchema = z.object({
},
{
message:
- "Certificate name schema must include the {{certificateId}} placeholder and 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}}, {{profileId}}, {{applicationId}}, {{commonName}}"
+ "Certificate name schema must include the {{certificateId}} or {{shortCertificateId}} placeholder and 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}}"
}
)
});
diff --git a/backend/src/services/pki-sync/netscaler/netscaler-pki-sync-fns.ts b/backend/src/services/pki-sync/netscaler/netscaler-pki-sync-fns.ts
index 7befc9fabb..bb06c1ceec 100644
--- a/backend/src/services/pki-sync/netscaler/netscaler-pki-sync-fns.ts
+++ b/backend/src/services/pki-sync/netscaler/netscaler-pki-sync-fns.ts
@@ -16,7 +16,9 @@ import { TCertificateMap } from "@app/services/pki-sync/pki-sync-types";
import {
buildManagedCertificateNameRegexSource,
certificateNameSchemaHasFreeTextPlaceholder,
- compileCertificateNameSchema
+ 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";
@@ -290,11 +292,13 @@ export const buildManagedCertNamePattern = (certificateNameSchema: string | unde
return new RE2("^Infisical-[0-9a-f]{32}(-[a-zA-Z0-9]*)?$");
}
- // {{certificateId}}, {{profileId}}, and {{applicationId}} resolve to dash-stripped UUIDs (32 hex chars).
- // {{commonName}} is arbitrary, so match any run of NetScaler-safe characters.
+ // {{certificateId}}, {{profileId}}, and {{applicationId}} resolve to 32-char dash-stripped UUIDs;
+ // {{shortCertificateId}} resolves to a 22-char base62 string.
+ // {{commonName}} and {{applicationName}} are arbitrary, so match any run of NetScaler-safe characters.
const pattern = buildManagedCertificateNameRegexSource(certificateNameSchema, {
- uuid: "[0-9a-f]{32}",
- commonName: "[a-zA-Z0-9._-]*"
+ uuid: UUID_NAME_REGEX_FRAGMENT,
+ shortUuid: SHORT_UUID_NAME_REGEX_FRAGMENT,
+ freeText: "[a-zA-Z0-9._-]*"
});
return new RE2(`^${pattern}$`);
@@ -437,6 +441,7 @@ export const netScalerPkiSyncFactory = ({
certificateId,
profileId: certData.profileId,
applicationId: pkiSync.applicationId,
+ applicationName: pkiSync.applicationName,
commonName: certData.commonName
},
PkiSync.NetScaler
diff --git a/backend/src/services/pki-sync/netscaler/netscaler-pki-sync-schemas.test.ts b/backend/src/services/pki-sync/netscaler/netscaler-pki-sync-schemas.test.ts
index 8b646878eb..aada4bc34c 100644
--- a/backend/src/services/pki-sync/netscaler/netscaler-pki-sync-schemas.test.ts
+++ b/backend/src/services/pki-sync/netscaler/netscaler-pki-sync-schemas.test.ts
@@ -7,11 +7,18 @@ describe("NetScaler certificateNameSchema validation", () => {
test("accepts the supported placeholders that fit the 63-char limit", () => {
expect(parseSchema("Infisical-{{certificateId}}")).toBe(true); // 42 chars
expect(parseSchema("{{commonName}}-{{certificateId}}")).toBe(true); // ~44 chars
+ expect(parseSchema("{{applicationName}}-{{certificateId}}")).toBe(true);
});
- test("requires the {{certificateId}} placeholder", () => {
+ test("accepts {{shortCertificateId}}, which fits where two full UUID placeholders would not", () => {
+ expect(parseSchema("Infisical-{{shortCertificateId}}")).toBe(true);
+ expect(parseSchema("{{applicationId}}-{{shortCertificateId}}")).toBe(true);
+ });
+
+ test("requires the {{certificateId}} or {{shortCertificateId}} placeholder", () => {
expect(parseSchema("{{commonName}}")).toBe(false);
expect(parseSchema("static-name")).toBe(false);
+ expect(parseSchema("{{profileId}}-{{applicationId}}")).toBe(false);
});
test("rejects the removed placeholders", () => {
@@ -25,10 +32,9 @@ describe("NetScaler certificateNameSchema validation", () => {
});
test("rejects schemas that compile beyond NetScaler's 63-char limit", () => {
- // two 32-char UUID placeholders + separator = 65 chars > 63
+ // two 32-char full UUID placeholders + separator = 65 chars > 63
expect(parseSchema("{{profileId}}-{{certificateId}}")).toBe(false);
expect(parseSchema("{{applicationId}}-{{certificateId}}")).toBe(false);
- expect(parseSchema("{{applicationId}}-{{profileId}}-{{certificateId}}")).toBe(false);
});
test("allows an empty/undefined schema (optional)", () => {
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 e72cd3f075..2f92e2837a 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
@@ -23,7 +23,7 @@ export const NetScalerPkiSyncOptionsSchema = z.object({
(schema) => {
if (!schema) return true;
- if (!schema.includes("{{certificateId}}")) {
+ if (!schema.includes("{{certificateId}}") && !schema.includes("{{shortCertificateId}}")) {
return false;
}
@@ -37,7 +37,7 @@ export const NetScalerPkiSyncOptionsSchema = z.object({
},
{
message:
- "Certificate name schema must include the {{certificateId}} placeholder and result in names that contain only alphanumeric characters, hyphens (-), underscores (_), and periods (.) and be 1-63 characters long for NetScaler. Available placeholders: {{certificateId}}, {{profileId}}, {{applicationId}}, {{commonName}}"
+ "Certificate name schema must include the {{certificateId}} or {{shortCertificateId}} placeholder and 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}}"
}
)
});
diff --git a/backend/src/services/pki-sync/pki-sync-certificate-name-fns.test.ts b/backend/src/services/pki-sync/pki-sync-certificate-name-fns.test.ts
index 20dd139843..dc2fffee8d 100644
--- a/backend/src/services/pki-sync/pki-sync-certificate-name-fns.test.ts
+++ b/backend/src/services/pki-sync/pki-sync-certificate-name-fns.test.ts
@@ -3,17 +3,42 @@ import {
buildManagedCertificateNameRegexSource,
certificateNameSchemaHasFreeTextPlaceholder,
compileCertificateNameSchema,
- sanitizeCertificateNameValue
+ sanitizeCertificateNameValue,
+ shortenUuid
} from "./pki-sync-certificate-name-fns";
import { PkiSync } from "./pki-sync-enums";
const CERT_ID = "550e8400-e29b-41d4-a716-446655440000";
const CERT_ID_CLEAN = "550e8400e29b41d4a716446655440000";
+const CERT_ID_SHORT = shortenUuid(CERT_ID);
const PROFILE_ID = "11111111-2222-3333-4444-555555555555";
const PROFILE_ID_CLEAN = "11111111222233334444555555555555";
const APP_ID = "abcdef00-1111-2222-3333-444444444444";
const APP_ID_CLEAN = "abcdef00111122223333444444444444";
+describe("shortenUuid", () => {
+ test("encodes a UUID as a fixed 22-char base62 string", () => {
+ expect(shortenUuid(CERT_ID)).toBe("2aUyqjCzEIiEcYMKj7TZtw");
+ expect(shortenUuid(CERT_ID)).toHaveLength(22);
+ });
+
+ test("is stable regardless of dashes in the input", () => {
+ expect(shortenUuid(CERT_ID)).toBe(shortenUuid(CERT_ID.replace(/-/g, "")));
+ });
+
+ test("left-pads small values to keep a fixed width", () => {
+ expect(shortenUuid("00000000-0000-0000-0000-000000000000")).toBe("0".repeat(22));
+ });
+
+ test("only ever emits base62 (alphanumeric) characters", () => {
+ expect(shortenUuid(APP_ID)).toMatch(/^[0-9A-Za-z]{22}$/);
+ });
+
+ test("falls back to the dash-stripped value when the input is not a UUID", () => {
+ expect(shortenUuid("not-a-uuid")).toBe("notauuid");
+ });
+});
+
describe("compileCertificateNameSchema", () => {
test("strips dashes from the certificate ID", () => {
expect(compileCertificateNameSchema("Infisical-{{certificateId}}", { certificateId: CERT_ID })).toBe(
@@ -21,6 +46,12 @@ describe("compileCertificateNameSchema", () => {
);
});
+ test("resolves {{shortCertificateId}} to the 22-char base62 form", () => {
+ expect(compileCertificateNameSchema("Infisical-{{shortCertificateId}}", { certificateId: CERT_ID })).toBe(
+ `Infisical-${CERT_ID_SHORT}`
+ );
+ });
+
test("substitutes the common name (FQDN) verbatim when no destination is given", () => {
expect(
compileCertificateNameSchema("{{commonName}}-{{certificateId}}", {
@@ -72,6 +103,22 @@ describe("compileCertificateNameSchema", () => {
});
});
+ test("substitutes the application name (sanitized per destination)", () => {
+ expect(
+ compileCertificateNameSchema(
+ "{{applicationName}}-{{certificateId}}",
+ { certificateId: CERT_ID, applicationName: "My App!" },
+ PkiSync.NetScaler
+ )
+ ).toBe(`My-App--${CERT_ID_CLEAN}`);
+ });
+
+ test("resolves application name to empty when the sync has no application", () => {
+ expect(compileCertificateNameSchema("app-{{applicationName}}-{{certificateId}}", { certificateId: CERT_ID })).toBe(
+ `app--${CERT_ID_CLEAN}`
+ );
+ });
+
test("substitutes the profile ID (dashes stripped)", () => {
expect(compileCertificateNameSchema("{{profileId}}", { certificateId: CERT_ID, profileId: PROFILE_ID })).toBe(
PROFILE_ID_CLEAN
@@ -113,17 +160,26 @@ describe("compileCertificateNameSchema", () => {
describe("buildCertificateNameSchemaTestName", () => {
const UUID = "0".repeat(32);
+ const SHORT_UUID = "0".repeat(22);
- test("substitutes UUID placeholders with full 32-char stand-ins (realistic length)", () => {
- expect(buildCertificateNameSchemaTestName("{{certificateId}}-{{profileId}}-{{applicationId}}-{{commonName}}")).toBe(
- `${UUID}-${UUID}-${UUID}-common-name`
- );
+ test("substitutes full placeholders with 32-char and {{shortCertificateId}} with 22-char stand-ins", () => {
+ expect(
+ buildCertificateNameSchemaTestName(
+ "{{certificateId}}-{{shortCertificateId}}-{{profileId}}-{{applicationId}}-{{applicationName}}-{{commonName}}"
+ )
+ ).toBe(`${UUID}-${SHORT_UUID}-${UUID}-${UUID}-application-name-common-name`);
});
- test("two UUID placeholders alone already exceed NetScaler's 63-char limit", () => {
+ test("two full UUID placeholders alone already exceed NetScaler's 63-char limit", () => {
expect(buildCertificateNameSchemaTestName("{{profileId}}-{{certificateId}}").length).toBeGreaterThan(63);
});
+ test("{{shortCertificateId}} keeps a combined schema within NetScaler's 63-char limit", () => {
+ expect(buildCertificateNameSchemaTestName("{{applicationId}}-{{shortCertificateId}}").length).toBeLessThanOrEqual(
+ 63
+ );
+ });
+
test("leaves removed placeholders untouched so destination validation rejects them", () => {
const testName = buildCertificateNameSchemaTestName("{{environment}}-{{friendlyName}}-{{certificateId}}");
// The leftover braces are forbidden characters for every destination, so validation fails.
@@ -149,7 +205,7 @@ describe("sanitizeCertificateNameValue", () => {
});
describe("buildManagedCertificateNameRegexSource", () => {
- const fragments = { uuid: "[0-9a-f]{32}", commonName: "[a-zA-Z0-9._-]*" };
+ const fragments = { uuid: "[0-9a-f]{32}", shortUuid: "[0-9A-Za-z]{22}", freeText: "[a-zA-Z0-9._-]*" };
test("substitutes placeholders and escapes literal regex characters", () => {
expect(buildManagedCertificateNameRegexSource("cert.{{certificateId}}", fragments)).toBe("cert\\.[0-9a-f]{32}");
@@ -158,6 +214,18 @@ describe("buildManagedCertificateNameRegexSource", () => {
);
});
+ test("uses the short fragment for {{shortCertificateId}}", () => {
+ expect(buildManagedCertificateNameRegexSource("cert-{{shortCertificateId}}", fragments)).toBe(
+ "cert-[0-9A-Za-z]{22}"
+ );
+ });
+
+ test("treats the application name as a free-text fragment", () => {
+ expect(buildManagedCertificateNameRegexSource("{{applicationName}}-{{certificateId}}", fragments)).toBe(
+ "[a-zA-Z0-9._-]*-[0-9a-f]{32}"
+ );
+ });
+
test("treats a sentinel-like literal as a literal, not a wildcard (no token-collision injection)", () => {
const source = buildManagedCertificateNameRegexSource(
"__INFISICAL_COMMON_NAME_PLACEHOLDER__-{{certificateId}}",
@@ -169,8 +237,9 @@ describe("buildManagedCertificateNameRegexSource", () => {
});
describe("certificateNameSchemaHasFreeTextPlaceholder", () => {
- test("true only for schemas containing the free-text {{commonName}} placeholder", () => {
+ test("true for schemas containing a free-text placeholder ({{commonName}} or {{applicationName}})", () => {
expect(certificateNameSchemaHasFreeTextPlaceholder("{{commonName}}-{{certificateId}}")).toBe(true);
+ expect(certificateNameSchemaHasFreeTextPlaceholder("{{applicationName}}-{{certificateId}}")).toBe(true);
expect(certificateNameSchemaHasFreeTextPlaceholder("Infisical-{{certificateId}}")).toBe(false);
expect(certificateNameSchemaHasFreeTextPlaceholder("{{profileId}}-{{applicationId}}-{{certificateId}}")).toBe(
false
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.ts
index fc1e43ab05..fd917d7478 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
@@ -5,15 +5,33 @@ import { PkiSync } from "./pki-sync-enums";
const DASH_REGEX = new RE2("-", "g");
-// A dash-stripped UUID is exactly 32 hex chars. The validation test name uses this so a
-// schema's real compiled length (e.g. two UUID placeholders = 64+ chars) is checked against
-// each destination's limit at configuration time instead of failing silently at sync time.
-const UUID_TEST_VALUE = "00000000000000000000000000000000";
+const BASE62_ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+const SHORTENED_UUID_LENGTH = 22;
+const HEX_UUID_REGEX = new RE2("^[0-9a-fA-F]{32}$");
+
+export const shortenUuid = (uuid: string): string => {
+ const hex = uuid.replace(DASH_REGEX, "");
+ if (!HEX_UUID_REGEX.test(hex)) return hex;
+
+ let value = BigInt(`0x${hex}`);
+ const base = BigInt(BASE62_ALPHABET.length);
+ let out = "";
+ while (value > BigInt(0)) {
+ out = BASE62_ALPHABET[Number(value % base)] + out;
+ value /= base;
+ }
+ return out.padStart(SHORTENED_UUID_LENGTH, "0");
+};
+
+// Full UUID placeholders resolve to 32 chars (dash-stripped); {{shortCertificateId}} resolves to 22.
+const UUID_TEST_VALUE = "0".repeat(32);
+const SHORT_UUID_TEST_VALUE = "0".repeat(SHORTENED_UUID_LENGTH);
// Per-destination set of characters allowed in a resource name. Free-text placeholder values
-// (currently {{commonName}}) are sanitized to this set at compile time so a FQDN like
-// "app.example.com" can't produce a name the destination rejects (e.g. Azure Key Vault and
-// Chef forbid dots). UUID-based placeholders are always safe (hex), so only free-text is sanitized.
+// ({{commonName}} and {{applicationName}}) are sanitized to this set at compile time so a value
+// like "app.example.com" can't produce a name the destination rejects (e.g. Azure Key Vault and
+// Chef forbid dots). ID-based placeholders are always safe (hex or base62), so only free-text is sanitized.
const NAME_VALUE_DISALLOWED_CHARS: Partial<Record<PkiSync, RE2>> = {
[PkiSync.AzureKeyVault]: new RE2("[^a-zA-Z0-9-]", "g"),
[PkiSync.CloudflareCustomCertificate]: new RE2("[^a-zA-Z0-9_-]", "g"),
@@ -33,24 +51,28 @@ export const sanitizeCertificateNameValue = (value: string, destination?: PkiSyn
export const UUID_NAME_REGEX_FRAGMENT = "[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}";
+export const SHORT_UUID_NAME_REGEX_FRAGMENT = "[0-9A-Za-z]{22}";
+
export const certificateNameSchemaHasFreeTextPlaceholder = (schema?: string): boolean =>
- Boolean(schema && schema.includes("{{commonName}}"));
+ Boolean(schema && (schema.includes("{{commonName}}") || schema.includes("{{applicationName}}")));
const PLACEHOLDER_OR_CHAR_REGEX = new RE2(
- "\\{\\{(certificateId|profileId|applicationId|commonName)\\}\\}|[\\s\\S]",
+ "\\{\\{(certificateId|shortCertificateId|profileId|applicationId|applicationName|commonName)\\}\\}|[\\s\\S]",
"g"
);
const REGEX_SPECIAL_CHARS = new RE2("[\\\\^$.*+?()\\[\\]{}|/]", "g");
export const buildManagedCertificateNameRegexSource = (
schema: string,
- fragments: { uuid: string; commonName: string }
+ fragments: { uuid: string; shortUuid: string; freeText: string }
): string => {
const fragmentByPlaceholder: Record<string, string> = {
certificateId: fragments.uuid,
+ shortCertificateId: fragments.shortUuid,
profileId: fragments.uuid,
applicationId: fragments.uuid,
- commonName: fragments.commonName
+ applicationName: fragments.freeText,
+ commonName: fragments.freeText
};
return schema.replace(PLACEHOLDER_OR_CHAR_REGEX, (match: string, placeholder?: string) =>
@@ -62,6 +84,7 @@ export type TCertificateNameSchemaData = {
certificateId: string;
profileId?: string | null;
applicationId?: string | null;
+ applicationName?: string | null;
commonName?: string | null;
};
@@ -69,13 +92,15 @@ export type TCertificateNameSchemaData = {
* Compiles a certificate name schema (Handlebars template) into a concrete name.
*
* Supported placeholders:
- * - {{certificateId}} - the certificate's unique ID (dashes stripped)
- * - {{profileId}} - the certificate profile ID (dashes stripped); falls back to {{certificateId}} when the certificate has no profile
- * - {{applicationId}} - the sync's application ID (dashes stripped); empty when the sync has no application
- * - {{commonName}} - the certificate common name (FQDN), sanitized to the destination's allowed character set
+ * - {{certificateId}} - the certificate's unique ID (dashes stripped, 32 chars)
+ * - {{shortCertificateId}} - the certificate's unique ID as a 22-char base62 string; use when the destination's name limit is tight
+ * - {{profileId}} - the certificate profile ID (dashes stripped); falls back to {{certificateId}} when the certificate has no profile
+ * - {{applicationId}} - the sync's application ID (dashes stripped); empty when the sync has no application
+ * - {{applicationName}} - the sync's application name, sanitized to the destination's allowed character set; empty when the sync has no application
+ * - {{commonName}} - the certificate common name (FQDN), sanitized to the destination's allowed character set
*
- * Callers pass raw values (UUIDs with dashes); cleaning and per-destination sanitization are
- * centralized here so every call site produces identical names.
+ * Callers pass raw values (UUIDs with dashes, free-text names); cleaning, shortening, and
+ * per-destination sanitization are centralized here so every call site produces identical names.
*/
export const compileCertificateNameSchema = (
schema: string,
@@ -88,8 +113,10 @@ export const compileCertificateNameSchema = (
return handlebars.compile(schema)({
certificateId,
+ shortCertificateId: shortenUuid(data.certificateId),
profileId,
applicationId,
+ applicationName: sanitizeCertificateNameValue(data.applicationName || "", destination),
commonName: sanitizeCertificateNameValue(data.commonName || "", destination)
});
};
@@ -98,13 +125,15 @@ export const compileCertificateNameSchema = (
* Substitutes every supported placeholder with a representative test value so that a
* destination's character/length constraints can be validated at configuration time.
*
- * UUID-based placeholders use a full 32-char value so the compiled length is realistic
- * (this is what catches over-length schemas, e.g. on NetScaler's 63-char limit).
- * Adding a new placeholder here makes it available to every destination's validation.
+ * Full UUID placeholders use a 32-char value and {{shortCertificateId}} a 22-char value so the
+ * compiled length is realistic (this is what catches over-length schemas, e.g. on NetScaler's
+ * 63-char limit). Adding a new placeholder here makes it available to every destination's validation.
*/
export const buildCertificateNameSchemaTestName = (schema: string): string =>
schema
+ .replace(new RE2("\\{\\{shortCertificateId\\}\\}", "g"), SHORT_UUID_TEST_VALUE)
.replace(new RE2("\\{\\{certificateId\\}\\}", "g"), UUID_TEST_VALUE)
.replace(new RE2("\\{\\{profileId\\}\\}", "g"), UUID_TEST_VALUE)
.replace(new RE2("\\{\\{applicationId\\}\\}", "g"), UUID_TEST_VALUE)
+ .replace(new RE2("\\{\\{applicationName\\}\\}", "g"), "application-name")
.replace(new RE2("\\{\\{commonName\\}\\}", "g"), "common-name");
diff --git a/backend/src/services/pki-sync/pki-sync-dal.ts b/backend/src/services/pki-sync/pki-sync-dal.ts
index e1571adcd6..73d379cdaf 100644
--- a/backend/src/services/pki-sync/pki-sync-dal.ts
+++ b/backend/src/services/pki-sync/pki-sync-dal.ts
@@ -18,6 +18,7 @@ type PkiSyncFindFilter = Parameters<typeof buildFindFilter<TPkiSyncs>>[0];
const basePkiSyncQuery = ({ filter, db, tx }: { db: TDbClient; filter?: PkiSyncFindFilter; tx?: Knex }) => {
const query = (tx || db.replicaNode())(TableName.PkiSync)
.leftJoin(TableName.AppConnection, `${TableName.PkiSync}.connectionId`, `${TableName.AppConnection}.id`)
+ .leftJoin(TableName.PkiApplication, `${TableName.PkiSync}.applicationId`, `${TableName.PkiApplication}.id`)
.select(selectAllTableCols(TableName.PkiSync))
.select(
// app connection fields
@@ -36,7 +37,8 @@ const basePkiSyncQuery = ({ filter, db, tx }: { db: TDbClient; filter?: PkiSyncF
db
.ref("isPlatformManagedCredentials")
.withSchema(TableName.AppConnection)
- .as("appConnectionIsPlatformManagedCredentials")
+ .as("appConnectionIsPlatformManagedCredentials"),
+ db.ref("name").withSchema(TableName.PkiApplication).as("applicationName")
);
if (filter) {
@@ -61,6 +63,7 @@ const basePkiSyncWithSubscriberQuery = ({
let query = (tx || db.replicaNode())(TableName.PkiSync)
.leftJoin(TableName.AppConnection, `${TableName.PkiSync}.connectionId`, `${TableName.AppConnection}.id`)
.leftJoin(TableName.PkiSubscriber, `${TableName.PkiSync}.subscriberId`, `${TableName.PkiSubscriber}.id`)
+ .leftJoin(TableName.PkiApplication, `${TableName.PkiSync}.applicationId`, `${TableName.PkiApplication}.id`)
.select(selectAllTableCols(TableName.PkiSync))
.select(
// app connection fields
@@ -80,6 +83,7 @@ const basePkiSyncWithSubscriberQuery = ({
.ref("isPlatformManagedCredentials")
.withSchema(TableName.AppConnection)
.as("appConnectionIsPlatformManagedCredentials"),
+ db.ref("name").withSchema(TableName.PkiApplication).as("applicationName"),
// pki subscriber fields
db.ref("id").withSchema(TableName.PkiSubscriber).as("pkiSubscriberId"),
db.ref("name").withSchema(TableName.PkiSubscriber).as("subscriberName")
diff --git a/backend/src/services/pki-sync/pki-sync-fns.ts b/backend/src/services/pki-sync/pki-sync-fns.ts
index ea90633fcb..429f265db1 100644
--- a/backend/src/services/pki-sync/pki-sync-fns.ts
+++ b/backend/src/services/pki-sync/pki-sync-fns.ts
@@ -26,7 +26,11 @@ import { F5_BIG_IP_PKI_SYNC_LIST_OPTION } from "./f5-big-ip/f5-big-ip-pki-sync-c
import { f5BigIpPkiSyncFactory } from "./f5-big-ip/f5-big-ip-pki-sync-fns";
import { NETSCALER_PKI_SYNC_LIST_OPTION } from "./netscaler/netscaler-pki-sync-constants";
import { netScalerPkiSyncFactory } from "./netscaler/netscaler-pki-sync-fns";
-import { buildManagedCertificateNameRegexSource, UUID_NAME_REGEX_FRAGMENT } from "./pki-sync-certificate-name-fns";
+import {
+ buildManagedCertificateNameRegexSource,
+ SHORT_UUID_NAME_REGEX_FRAGMENT,
+ UUID_NAME_REGEX_FRAGMENT
+} from "./pki-sync-certificate-name-fns";
import { PkiSync } from "./pki-sync-enums";
import { TCertificateMap, TPkiSyncWithCredentials } from "./pki-sync-types";
@@ -95,7 +99,8 @@ export const matchesCertificateNameSchema = (name: string, schema?: string): boo
const pattern = buildManagedCertificateNameRegexSource(schema, {
uuid: UUID_NAME_REGEX_FRAGMENT,
- commonName: "[a-zA-Z0-9._-]*"
+ shortUuid: SHORT_UUID_NAME_REGEX_FRAGMENT,
+ freeText: "[a-zA-Z0-9._-]*"
});
return new RE2(`^${pattern}$`).test(name);
diff --git a/backend/src/services/pki-sync/pki-sync-queue.ts b/backend/src/services/pki-sync/pki-sync-queue.ts
index 5ee93905cc..a0df4b1437 100644
--- a/backend/src/services/pki-sync/pki-sync-queue.ts
+++ b/backend/src/services/pki-sync/pki-sync-queue.ts
@@ -295,6 +295,7 @@ export const pkiSyncQueueFactory = ({
certificateId: certificate.id,
profileId: cert.profileId,
applicationId: pkiSync.applicationId,
+ applicationName: pkiSync.applicationName,
commonName: cert.commonName
},
pkiSync.destination as PkiSync
diff --git a/backend/src/services/pki-sync/pki-sync-schemas.ts b/backend/src/services/pki-sync/pki-sync-schemas.ts
index 1a6c6bc835..55fc28d55c 100644
--- a/backend/src/services/pki-sync/pki-sync-schemas.ts
+++ b/backend/src/services/pki-sync/pki-sync-schemas.ts
@@ -17,8 +17,10 @@ export const PkiSyncOptionsSchema = z.object({
const allowedPlaceholdersRegexPart = [
"{{certificateId}}",
+ "{{shortCertificateId}}",
"{{profileId}}",
"{{applicationId}}",
+ "{{applicationName}}",
"{{commonName}}"
]
.map((p) => p.replace(new RE2(/[-/\\^$*+?.()|[\]{}]/g), "\\$&")) // Escape regex special characters
@@ -28,8 +30,7 @@ export const PkiSyncOptionsSchema = z.object({
const contentIsValid = allowedContentRegex.test(val);
if (val.trim()) {
- const certificateIdRegex = new RE2(/\{\{certificateId\}\}/);
- const certificateIdIsPresent = certificateIdRegex.test(val);
+ const certificateIdIsPresent = val.includes("{{certificateId}}") || val.includes("{{shortCertificateId}}");
return contentIsValid && certificateIdIsPresent;
}
@@ -37,7 +38,7 @@ export const PkiSyncOptionsSchema = z.object({
},
{
message:
- "Certificate name schema must include the {{certificateId}} placeholder. It can also include {{profileId}}, {{applicationId}}, and {{commonName}} placeholders. Only alphanumeric characters (a-z, A-Z, 0-9), dashes (-), underscores (_), and slashes (/) are allowed besides the placeholders."
+ "Certificate name schema must include the {{certificateId}} or {{shortCertificateId}} placeholder. It can also include {{profileId}}, {{applicationId}}, {{applicationName}}, and {{commonName}} placeholders. Only alphanumeric characters (a-z, A-Z, 0-9), dashes (-), underscores (_), and slashes (/) are allowed besides the placeholders."
}
)
});
diff --git a/backend/src/services/pki-sync/pki-sync-types.ts b/backend/src/services/pki-sync/pki-sync-types.ts
index 83e4dfe442..758175a92f 100644
--- a/backend/src/services/pki-sync/pki-sync-types.ts
+++ b/backend/src/services/pki-sync/pki-sync-types.ts
@@ -19,6 +19,7 @@ export type TPkiSync = {
syncOptions: Record<string, unknown>;
projectId: string;
applicationId?: string | null;
+ applicationName?: string | null;
subscriberId?: string;
connectionId: string;
createdAt: Date;
diff --git a/docs/documentation/platform/pki/applications/certificate-syncs/netscaler.mdx b/docs/documentation/platform/pki/applications/certificate-syncs/netscaler.mdx
index 20b5babc34..572c8189d6 100644
--- a/docs/documentation/platform/pki/applications/certificate-syncs/netscaler.mdx
+++ b/docs/documentation/platform/pki/applications/certificate-syncs/netscaler.mdx
@@ -107,7 +107,7 @@ Deploy certificates to Citrix NetScaler ADC appliances via the NITRO API. Certif
</Tabs>
<Note>
- NetScaler caps `sslcertkey` names at **63 characters**. Since `{{certificateId}}` is required and each UUID placeholder (`{{certificateId}}`, `{{profileId}}`, `{{applicationId}}`) resolves to 32 characters, combining two of them exceeds the limit and the schema is rejected when you save the sync. For NetScaler, pair `{{certificateId}}` with a short prefix or `{{commonName}}` (kept under the limit).
+ NetScaler caps `sslcertkey` names at **63 characters**. Full UUID placeholders (`{{certificateId}}`, `{{profileId}}`, `{{applicationId}}`) each resolve to 32 characters, so combining two of them exceeds the limit and the schema is rejected when you save the sync. For tight schemas, use `{{shortCertificateId}}` (22 characters) in place of `{{certificateId}}`, optionally with a short prefix or `{{commonName}}`.
</Note>
## Certificate Management
diff --git a/docs/documentation/platform/pki/applications/certificate-syncs/overview.mdx b/docs/documentation/platform/pki/applications/certificate-syncs/overview.mdx
index f9c5105ca3..6f28e3919a 100644
--- a/docs/documentation/platform/pki/applications/certificate-syncs/overview.mdx
+++ b/docs/documentation/platform/pki/applications/certificate-syncs/overview.mdx
@@ -122,20 +122,22 @@ flowchart LR
The **Certificate Name Schema** controls the name each certificate is given in the destination. It is a template that supports the following placeholders, which are resolved per certificate at sync time:
<Note>
- - `{{certificateId}}` - The unique ID of the certificate. **Required** so that each synced certificate resolves to a unique, stable name.
+ - `{{certificateId}}` - The unique ID of the certificate (32 characters). **Required** (or `{{shortCertificateId}}`) so that each synced certificate resolves to a unique, stable name.
+ - `{{shortCertificateId}}` - A shorter (22-character) form of the certificate ID. Use it in place of `{{certificateId}}` when the destination's name limit is tight (e.g. NetScaler). It guarantees the same per-certificate uniqueness.
- `{{commonName}}` - The certificate's common name (its FQDN), e.g. `app.example.com`.
- `{{profileId}}` - The certificate profile ID. Falls back to the certificate ID when the certificate has no profile.
- `{{applicationId}}` - The ID of the application the sync belongs to.
+ - `{{applicationName}}` - The name of the application the sync belongs to.
</Note>
For example, `myapp-{{commonName}}-{{certificateId}}` produces a name like `myapp-app.example.com-1a2b3c...`.
Each destination enforces its own character and length rules for resource names:
-- **Characters**: `{{commonName}}` is sanitized to the destination's allowed character set. For destinations that don't allow dots (e.g. Azure Key Vault, Chef), `app.example.com` becomes `app-example-com`; destinations that allow dots (e.g. NetScaler, F5 BIG-IP) keep it as-is.
-- **Length**: schemas that would compile to a name longer than the destination's limit are rejected when you save the sync. UUID placeholders (`{{certificateId}}`, `{{profileId}}`, `{{applicationId}}`) each count as 32 characters.
+- **Characters**: `{{commonName}}` and `{{applicationName}}` are sanitized to the destination's allowed character set. For destinations that don't allow dots (e.g. Azure Key Vault, Chef), `app.example.com` becomes `app-example-com`; destinations that allow dots (e.g. NetScaler, F5 BIG-IP) keep it as-is.
+- **Length**: schemas that would compile to a name longer than the destination's limit are rejected when you save the sync. Full UUID placeholders (`{{certificateId}}`, `{{profileId}}`, `{{applicationId}}`) each count as 32 characters; `{{shortCertificateId}}` counts as 22. For tight limits, prefer `{{shortCertificateId}}`.
-Keep `{{certificateId}}` in the schema to guarantee a unique, stable name per certificate.
+Keep `{{certificateId}}` or `{{shortCertificateId}}` in the schema to guarantee a unique, stable name per certificate.
## What's Next?
diff --git a/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsx b/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsx
index 284cc22311..36a9ce9448 100644
--- a/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsx
+++ b/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsx
@@ -434,6 +434,11 @@ export const PkiSyncOptionsFields = ({ destination }: Props) => {
<li>
<code>{"{{certificateId}}"}</code> - The unique ID of the certificate
</li>
+ <li>
+ <code>{"{{shortCertificateId}}"}</code> - A shorter (22-character) form of the
+ certificate ID. Use it instead of <code>{"{{certificateId}}"}</code> when the
+ destination&apos;s name limit is tight (e.g. NetScaler&apos;s 63 characters).
+ </li>
<li>
<code>{"{{commonName}}"}</code> - The certificate&apos;s common name (FQDN)
</li>
@@ -445,10 +450,15 @@ export const PkiSyncOptionsFields = ({ destination }: Props) => {
<code>{"{{applicationId}}"}</code> - The ID of the application the sync
belongs to
</li>
+ <li>
+ <code>{"{{applicationName}}"}</code> - The name of the application the sync
+ belongs to
+ </li>
</ul>
<span className="mt-1 text-xs text-bunker-300">
- The schema must include <code>{"{{certificateId}}"}</code> so each certificate
- gets a unique name. The template itself can only contain letters, numbers, and
+ The schema must include <code>{"{{certificateId}}"}</code> or{" "}
+ <code>{"{{shortCertificateId}}"}</code> so each certificate gets a unique name.
+ The template itself can only contain letters, numbers, and
the separators allowed by the destination. When placeholders resolve, any
characters the destination doesn&apos;t support are replaced with hyphens.
</span>
@@ -467,7 +477,7 @@ export const PkiSyncOptionsFields = ({ destination }: Props) => {
</div>
}
isError={Boolean(error)}
- isOptional
+ isOptional={currentDestination === PkiSync.AwsElasticLoadBalancer}
errorText={error?.message}
label="Certificate Name Schema"
helperText="Infisical strongly advises setting a Certificate Name Schema to ensure that Infisical only manages the specific certificates you intend to manage, keeping everything else untouched."
diff --git a/frontend/src/components/pki-syncs/forms/schemas/aws-certificate-manager-pki-sync-destination-schema.ts b/frontend/src/components/pki-syncs/forms/schemas/aws-certificate-manager-pki-sync-destination-schema.ts
index 13fcc2bd17..9ab3438c09 100644
--- a/frontend/src/components/pki-syncs/forms/schemas/aws-certificate-manager-pki-sync-destination-schema.ts
+++ b/frontend/src/components/pki-syncs/forms/schemas/aws-certificate-manager-pki-sync-destination-schema.ts
@@ -11,22 +11,26 @@ const AwsCertificateManagerSyncOptionsSchema = z.object({
preserveArn: z.boolean().default(true),
certificateNameSchema: z
.string()
- .optional()
+ .trim()
+ .min(1, "Certificate name schema is required")
.refine(
(val) => {
- // For AWS Certificate Manager, {{certificateId}} is always required if certificateNameSchema is provided
- if (!val) return true;
-
- if (!val.includes("{{certificateId}}")) {
+ // For AWS Certificate Manager, {{certificateId}} or {{shortCertificateId}} is always required
+ if (!val.includes("{{certificateId}}") && !val.includes("{{shortCertificateId}}")) {
return false;
}
const allowedOptionalPlaceholders = [
"{{profileId}}",
"{{applicationId}}",
+ "{{applicationName}}",
"{{commonName}}"
];
- const allowedPlaceholdersRegexPart = ["{{certificateId}}", ...allowedOptionalPlaceholders]
+ const allowedPlaceholdersRegexPart = [
+ "{{certificateId}}",
+ "{{shortCertificateId}}",
+ ...allowedOptionalPlaceholders
+ ]
.map((p) => p.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"))
.join("|");
@@ -38,7 +42,7 @@ const AwsCertificateManagerSyncOptionsSchema = z.object({
},
{
message:
- "Certificate name schema must include the {{certificateId}} placeholder for AWS Certificate Manager. It can also include {{profileId}}, {{applicationId}}, and {{commonName}} placeholders."
+ "Certificate name schema must include the {{certificateId}} or {{shortCertificateId}} placeholder for AWS Certificate Manager. It can also include {{profileId}}, {{applicationId}}, {{applicationName}}, and {{commonName}} placeholders."
}
)
});
diff --git a/frontend/src/components/pki-syncs/forms/schemas/aws-secrets-manager-pki-sync-destination-schema.ts b/frontend/src/components/pki-syncs/forms/schemas/aws-secrets-manager-pki-sync-destination-schema.ts
index 81b31a29c8..523d51d70a 100644
--- a/frontend/src/components/pki-syncs/forms/schemas/aws-secrets-manager-pki-sync-destination-schema.ts
+++ b/frontend/src/components/pki-syncs/forms/schemas/aws-secrets-manager-pki-sync-destination-schema.ts
@@ -25,18 +25,22 @@ const AwsSecretsManagerSyncOptionsSchema = z.object({
updateExistingCertificates: z.boolean().default(true),
certificateNameSchema: z
.string()
- .optional()
+ .trim()
+ .min(1, "Certificate name schema is required")
.refine(
(val) => {
- if (!val) return true;
-
const allowedOptionalPlaceholders = [
"{{profileId}}",
"{{applicationId}}",
+ "{{applicationName}}",
"{{commonName}}"
];
- const allowedPlaceholdersRegexPart = ["{{certificateId}}", ...allowedOptionalPlaceholders]
+ const allowedPlaceholdersRegexPart = [
+ "{{certificateId}}",
+ "{{shortCertificateId}}",
+ ...allowedOptionalPlaceholders
+ ]
.map((p) => p.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"))
.join("|");
@@ -45,17 +49,13 @@ const AwsSecretsManagerSyncOptionsSchema = z.object({
);
const contentIsValid = allowedContentRegex.test(val);
- if (val.trim()) {
- const certificateIdRegex = /\{\{certificateId\}\}/;
- const certificateIdIsPresent = certificateIdRegex.test(val);
- return contentIsValid && certificateIdIsPresent;
- }
-
- return contentIsValid;
+ const certificateIdIsPresent =
+ val.includes("{{certificateId}}") || val.includes("{{shortCertificateId}}");
+ return contentIsValid && certificateIdIsPresent;
},
{
message:
- "Certificate name schema must include exactly one {{certificateId}} placeholder. It can also include {{profileId}}, {{applicationId}}, and {{commonName}} placeholders. Only alphanumeric characters (a-z, A-Z, 0-9), hyphens (-), and underscores (_) are allowed besides the placeholders."
+ "Certificate name schema must include the {{certificateId}} or {{shortCertificateId}} placeholder. It can also include {{profileId}}, {{applicationId}}, {{applicationName}}, and {{commonName}} placeholders. Only alphanumeric characters (a-z, A-Z, 0-9), hyphens (-), and underscores (_) are allowed besides the placeholders."
}
),
fieldMappings: AwsSecretsManagerFieldMappingsSchema.optional().default({
diff --git a/frontend/src/components/pki-syncs/forms/schemas/azure-key-vault-pki-sync-destination-schema.ts b/frontend/src/components/pki-syncs/forms/schemas/azure-key-vault-pki-sync-destination-schema.ts
index ba2301fcce..bdf9ccb481 100644
--- a/frontend/src/components/pki-syncs/forms/schemas/azure-key-vault-pki-sync-destination-schema.ts
+++ b/frontend/src/components/pki-syncs/forms/schemas/azure-key-vault-pki-sync-destination-schema.ts
@@ -11,18 +11,22 @@ const AzureKeyVaultSyncOptionsSchema = z.object({
enableVersioning: z.boolean().default(true),
certificateNameSchema: z
.string()
- .optional()
+ .trim()
+ .min(1, "Certificate name schema is required")
.refine(
(val) => {
- if (!val) return true;
-
const allowedOptionalPlaceholders = [
"{{profileId}}",
"{{applicationId}}",
+ "{{applicationName}}",
"{{commonName}}"
];
- const allowedPlaceholdersRegexPart = ["{{certificateId}}", ...allowedOptionalPlaceholders]
+ const allowedPlaceholdersRegexPart = [
+ "{{certificateId}}",
+ "{{shortCertificateId}}",
+ ...allowedOptionalPlaceholders
+ ]
.map((p) => p.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"))
.join("|");
@@ -31,17 +35,13 @@ const AzureKeyVaultSyncOptionsSchema = z.object({
);
const contentIsValid = allowedContentRegex.test(val);
- if (val.trim()) {
- const certificateIdRegex = /\{\{certificateId\}\}/;
- const certificateIdIsPresent = certificateIdRegex.test(val);
- return contentIsValid && certificateIdIsPresent;
- }
-
- return contentIsValid;
+ const certificateIdIsPresent =
+ val.includes("{{certificateId}}") || val.includes("{{shortCertificateId}}");
+ return contentIsValid && certificateIdIsPresent;
},
{
message:
- "Certificate name schema must include the {{certificateId}} placeholder. It can also include {{profileId}}, {{applicationId}}, and {{commonName}} placeholders. Only alphanumeric characters (a-z, A-Z, 0-9), dashes (-), underscores (_), and slashes (/) are allowed besides the placeholders."
+ "Certificate name schema must include the {{certificateId}} or {{shortCertificateId}} placeholder. It can also include {{profileId}}, {{applicationId}}, {{applicationName}}, and {{commonName}} placeholders. Only alphanumeric characters (a-z, A-Z, 0-9), dashes (-), underscores (_), and slashes (/) are allowed besides the placeholders."
}
)
});
diff --git a/frontend/src/components/pki-syncs/forms/schemas/base-pki-sync-schema.ts b/frontend/src/components/pki-syncs/forms/schemas/base-pki-sync-schema.ts
index 96317215f8..384c97657e 100644
--- a/frontend/src/components/pki-syncs/forms/schemas/base-pki-sync-schema.ts
+++ b/frontend/src/components/pki-syncs/forms/schemas/base-pki-sync-schema.ts
@@ -9,18 +9,22 @@ export const BasePkiSyncSchema = <T extends AnyZodObject | undefined = undefined
includeRootCa: z.boolean().default(false),
certificateNameSchema: z
.string()
- .optional()
+ .trim()
+ .min(1, "Certificate name schema is required")
.refine(
(val) => {
- if (!val) return true;
-
const allowedOptionalPlaceholders = [
"{{profileId}}",
"{{applicationId}}",
+ "{{applicationName}}",
"{{commonName}}"
];
- const allowedPlaceholdersRegexPart = ["{{certificateId}}", ...allowedOptionalPlaceholders]
+ const allowedPlaceholdersRegexPart = [
+ "{{certificateId}}",
+ "{{shortCertificateId}}",
+ ...allowedOptionalPlaceholders
+ ]
.map((p) => p.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")) // Escape regex special characters
.join("|");
@@ -29,17 +33,13 @@ export const BasePkiSyncSchema = <T extends AnyZodObject | undefined = undefined
);
const contentIsValid = allowedContentRegex.test(val);
- if (val.trim()) {
- const certificateIdRegex = /\{\{certificateId\}\}/;
- const certificateIdIsPresent = certificateIdRegex.test(val);
- return contentIsValid && certificateIdIsPresent;
- }
-
- return contentIsValid;
+ const certificateIdIsPresent =
+ val.includes("{{certificateId}}") || val.includes("{{shortCertificateId}}");
+ return contentIsValid && certificateIdIsPresent;
},
{
message:
- "Certificate name schema must include the {{certificateId}} placeholder. It can also include {{profileId}}, {{applicationId}}, and {{commonName}} placeholders. Only alphanumeric characters (a-z, A-Z, 0-9), dashes (-), underscores (_), and slashes (/) are allowed besides the placeholders."
+ "Certificate name schema must include the {{certificateId}} or {{shortCertificateId}} placeholder. It can also include {{profileId}}, {{applicationId}}, {{applicationName}}, and {{commonName}} placeholders. Only alphanumeric characters (a-z, A-Z, 0-9), dashes (-), underscores (_), and slashes (/) are allowed besides the placeholders."
}
)
});
diff --git a/frontend/src/components/pki-syncs/forms/schemas/chef-pki-sync-destination-schema.ts b/frontend/src/components/pki-syncs/forms/schemas/chef-pki-sync-destination-schema.ts
index 50d2d40f4a..2c0862fa13 100644
--- a/frontend/src/components/pki-syncs/forms/schemas/chef-pki-sync-destination-schema.ts
+++ b/frontend/src/components/pki-syncs/forms/schemas/chef-pki-sync-destination-schema.ts
@@ -25,18 +25,22 @@ const ChefSyncOptionsSchema = z.object({
updateExistingCertificates: z.boolean().default(true),
certificateNameSchema: z
.string()
- .optional()
+ .trim()
+ .min(1, "Certificate item name schema is required")
.refine(
(val) => {
- if (!val) return true;
-
const allowedOptionalPlaceholders = [
"{{profileId}}",
"{{applicationId}}",
+ "{{applicationName}}",
"{{commonName}}"
];
- const allowedPlaceholdersRegexPart = ["{{certificateId}}", ...allowedOptionalPlaceholders]
+ const allowedPlaceholdersRegexPart = [
+ "{{certificateId}}",
+ "{{shortCertificateId}}",
+ ...allowedOptionalPlaceholders
+ ]
.map((p) => p.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"))
.join("|");
@@ -45,17 +49,13 @@ const ChefSyncOptionsSchema = z.object({
);
const contentIsValid = allowedContentRegex.test(val);
- if (val.trim()) {
- const certificateIdRegex = /\{\{certificateId\}\}/;
- const certificateIdIsPresent = certificateIdRegex.test(val);
- return contentIsValid && certificateIdIsPresent;
- }
-
- return contentIsValid;
+ const certificateIdIsPresent =
+ val.includes("{{certificateId}}") || val.includes("{{shortCertificateId}}");
+ return contentIsValid && certificateIdIsPresent;
},
{
message:
- "Certificate item name schema must include exactly one {{certificateId}} placeholder. It can also include {{profileId}}, {{applicationId}}, and {{commonName}} placeholders. Only alphanumeric characters (a-z, A-Z, 0-9), hyphens (-), and underscores (_) are allowed besides the placeholders."
+ "Certificate item name schema must include the {{certificateId}} or {{shortCertificateId}} placeholder. It can also include {{profileId}}, {{applicationId}}, {{applicationName}}, and {{commonName}} placeholders. Only alphanumeric characters (a-z, A-Z, 0-9), hyphens (-), and underscores (_) are allowed besides the placeholders."
}
),
fieldMappings: ChefFieldMappingsSchema.optional().default({
diff --git a/frontend/src/components/pki-syncs/forms/schemas/cloudflare-custom-certificate-pki-sync-destination-schema.ts b/frontend/src/components/pki-syncs/forms/schemas/cloudflare-custom-certificate-pki-sync-destination-schema.ts
index a18a0e99a4..e3f6d87d69 100644
--- a/frontend/src/components/pki-syncs/forms/schemas/cloudflare-custom-certificate-pki-sync-destination-schema.ts
+++ b/frontend/src/components/pki-syncs/forms/schemas/cloudflare-custom-certificate-pki-sync-destination-schema.ts
@@ -9,18 +9,22 @@ const CloudflareCustomCertificateSyncOptionsSchema = z.object({
canRemoveCertificates: z.boolean().default(true),
certificateNameSchema: z
.string()
- .optional()
+ .trim()
+ .min(1, "Certificate name schema is required")
.refine(
(val) => {
- if (!val) return true;
-
const allowedOptionalPlaceholders = [
"{{profileId}}",
"{{applicationId}}",
+ "{{applicationName}}",
"{{commonName}}"
];
- const allowedPlaceholdersRegexPart = ["{{certificateId}}", ...allowedOptionalPlaceholders]
+ const allowedPlaceholdersRegexPart = [
+ "{{certificateId}}",
+ "{{shortCertificateId}}",
+ ...allowedOptionalPlaceholders
+ ]
.map((p) => p.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"))
.join("|");
@@ -29,17 +33,13 @@ const CloudflareCustomCertificateSyncOptionsSchema = z.object({
);
const contentIsValid = allowedContentRegex.test(val);
- if (val.trim()) {
- const certificateIdRegex = /\{\{certificateId\}\}/;
- const certificateIdIsPresent = certificateIdRegex.test(val);
- return contentIsValid && certificateIdIsPresent;
- }
-
- return contentIsValid;
+ const certificateIdIsPresent =
+ val.includes("{{certificateId}}") || val.includes("{{shortCertificateId}}");
+ return contentIsValid && certificateIdIsPresent;
},
{
message:
- "Certificate name schema must include the {{certificateId}} placeholder. It can also include {{profileId}}, {{applicationId}}, and {{commonName}} placeholders. Only alphanumeric characters (a-z, A-Z, 0-9), dashes (-), and underscores (_) are allowed besides the placeholders."
+ "Certificate name schema must include the {{certificateId}} or {{shortCertificateId}} placeholder. It can also include {{profileId}}, {{applicationId}}, {{applicationName}}, and {{commonName}} placeholders. Only alphanumeric characters (a-z, A-Z, 0-9), dashes (-), and underscores (_) are allowed besides the placeholders."
}
)
});
diff --git a/frontend/src/components/pki-syncs/forms/schemas/f5-big-ip-pki-sync-destination-schema.ts b/frontend/src/components/pki-syncs/forms/schemas/f5-big-ip-pki-sync-destination-schema.ts
index 6149fd6e7f..cfab2856f3 100644
--- a/frontend/src/components/pki-syncs/forms/schemas/f5-big-ip-pki-sync-destination-schema.ts
+++ b/frontend/src/components/pki-syncs/forms/schemas/f5-big-ip-pki-sync-destination-schema.ts
@@ -13,18 +13,22 @@ const F5BigIpSyncOptionsSchema = z.object({
preserveItemOnRenewal: z.boolean().default(true),
certificateNameSchema: z
.string()
- .optional()
+ .trim()
+ .min(1, "Certificate name schema is required")
.refine(
(val) => {
- if (!val) return true;
-
const allowedOptionalPlaceholders = [
"{{profileId}}",
"{{applicationId}}",
+ "{{applicationName}}",
"{{commonName}}"
];
- const allowedPlaceholdersRegexPart = ["{{certificateId}}", ...allowedOptionalPlaceholders]
+ const allowedPlaceholdersRegexPart = [
+ "{{certificateId}}",
+ "{{shortCertificateId}}",
+ ...allowedOptionalPlaceholders
+ ]
.map((p) => p.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"))
.join("|");
@@ -33,17 +37,13 @@ const F5BigIpSyncOptionsSchema = z.object({
);
const contentIsValid = allowedContentRegex.test(val);
- if (val.trim()) {
- const certificateIdRegex = /\{\{certificateId\}\}/;
- const certificateIdIsPresent = certificateIdRegex.test(val);
- return contentIsValid && certificateIdIsPresent;
- }
-
- return contentIsValid;
+ const certificateIdIsPresent =
+ val.includes("{{certificateId}}") || val.includes("{{shortCertificateId}}");
+ return contentIsValid && certificateIdIsPresent;
},
{
message:
- "Certificate name schema must include the {{certificateId}} placeholder. It can also include {{profileId}}, {{applicationId}}, and {{commonName}} placeholders. Only alphanumeric characters (a-z, A-Z, 0-9), dashes (-), underscores (_), and periods (.) are allowed besides the placeholders."
+ "Certificate name schema must include the {{certificateId}} or {{shortCertificateId}} placeholder. It can also include {{profileId}}, {{applicationId}}, {{applicationName}}, and {{commonName}} placeholders. Only alphanumeric characters (a-z, A-Z, 0-9), dashes (-), underscores (_), and periods (.) are allowed besides the placeholders."
}
)
});
diff --git a/frontend/src/components/pki-syncs/forms/schemas/netscaler-pki-sync-destination-schema.ts b/frontend/src/components/pki-syncs/forms/schemas/netscaler-pki-sync-destination-schema.ts
index 5e844029c8..fd49373b84 100644
--- a/frontend/src/components/pki-syncs/forms/schemas/netscaler-pki-sync-destination-schema.ts
+++ b/frontend/src/components/pki-syncs/forms/schemas/netscaler-pki-sync-destination-schema.ts
@@ -10,18 +10,22 @@ const NetScalerSyncOptionsSchema = z.object({
preserveItemOnRenewal: z.boolean().default(true),
certificateNameSchema: z
.string()
- .optional()
+ .trim()
+ .min(1, "Certificate name schema is required")
.refine(
(val) => {
- if (!val) return true;
-
const allowedOptionalPlaceholders = [
"{{profileId}}",
"{{applicationId}}",
+ "{{applicationName}}",
"{{commonName}}"
];
- const allowedPlaceholdersRegexPart = ["{{certificateId}}", ...allowedOptionalPlaceholders]
+ const allowedPlaceholdersRegexPart = [
+ "{{certificateId}}",
+ "{{shortCertificateId}}",
+ ...allowedOptionalPlaceholders
+ ]
.map((p) => p.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"))
.join("|");
@@ -30,26 +34,24 @@ const NetScalerSyncOptionsSchema = z.object({
);
const contentIsValid = allowedContentRegex.test(val);
- // NetScaler caps certkey names at 63 chars. UUID placeholders resolve to 32 chars each,
- // so check the realistic compiled length to reject over-limit schemas before sync time.
+ // NetScaler caps certkey names at 63 chars. Full UUID placeholders resolve to 32 chars and
+ // {{shortCertificateId}} to 22
const compiledLength = val
+ .replace(/\{\{shortCertificateId\}\}/g, "0".repeat(22))
.replace(/\{\{certificateId\}\}/g, "0".repeat(32))
.replace(/\{\{profileId\}\}/g, "0".repeat(32))
.replace(/\{\{applicationId\}\}/g, "0".repeat(32))
+ .replace(/\{\{applicationName\}\}/g, "application-name")
.replace(/\{\{commonName\}\}/g, "common-name").length;
const lengthIsValid = compiledLength <= 63;
- if (val.trim()) {
- const certificateIdRegex = /\{\{certificateId\}\}/;
- const certificateIdIsPresent = certificateIdRegex.test(val);
- return contentIsValid && certificateIdIsPresent && lengthIsValid;
- }
-
- return contentIsValid;
+ const certificateIdIsPresent =
+ val.includes("{{certificateId}}") || val.includes("{{shortCertificateId}}");
+ return contentIsValid && certificateIdIsPresent && lengthIsValid;
},
{
message:
- "Certificate name schema must include the {{certificateId}} placeholder and compile to at most 63 characters for NetScaler (each UUID placeholder counts as 32 characters). It can also include {{profileId}}, {{applicationId}}, and {{commonName}} placeholders. Only alphanumeric characters (a-z, A-Z, 0-9), dashes (-), underscores (_), and periods (.) are allowed besides the placeholders."
+ "Certificate name schema must include the {{certificateId}} or {{shortCertificateId}} placeholder and compile to at most 63 characters for NetScaler ({{certificateId}}, {{profileId}}, and {{applicationId}} count as 32 characters each; {{shortCertificateId}} counts as 22). It can also include {{profileId}}, {{applicationId}}, {{applicationName}}, and {{commonName}} placeholders. Only alphanumeric characters (a-z, A-Z, 0-9), dashes (-), underscores (_), and periods (.) are allowed besides the placeholders."
}
)
});