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
Add PKI Cloudflare Sync
Carlos Monastyrskie7184b71fd3c
diff --git a/backend/src/server/routes/v1/pki-sync-routers/cloudflare-custom-certificate-pki-sync-router.ts b/backend/src/server/routes/v1/pki-sync-routers/cloudflare-custom-certificate-pki-sync-router.tsnew file mode 100644index 0000000000..c43bb9c83b--- /dev/null+++ b/backend/src/server/routes/v1/pki-sync-routers/cloudflare-custom-certificate-pki-sync-router.ts@@ -0,0 +1,26 @@+import {+ CLOUDFLARE_CUSTOM_CERTIFICATE_PKI_SYNC_LIST_OPTION,+ CloudflareCustomCertificatePkiSyncSchema,+ CreateCloudflareCustomCertificatePkiSyncSchema,+ UpdateCloudflareCustomCertificatePkiSyncSchema+} from "@app/services/pki-sync/cloudflare-custom-certificate";+import { PkiSync } from "@app/services/pki-sync/pki-sync-enums";++import { registerSyncPkiEndpoints } from "./pki-sync-endpoints";++export const registerCloudflareCustomCertificatePkiSyncRouter = async (+ server: FastifyZodProvider,+ enableOperationId: boolean = true+) =>+ registerSyncPkiEndpoints({+ destination: PkiSync.CloudflareCustomCertificate,+ server,+ responseSchema: CloudflareCustomCertificatePkiSyncSchema,+ createSchema: CreateCloudflareCustomCertificatePkiSyncSchema,+ updateSchema: UpdateCloudflareCustomCertificatePkiSyncSchema,+ syncOptions: {+ canImportCertificates: CLOUDFLARE_CUSTOM_CERTIFICATE_PKI_SYNC_LIST_OPTION.canImportCertificates,+ canRemoveCertificates: CLOUDFLARE_CUSTOM_CERTIFICATE_PKI_SYNC_LIST_OPTION.canRemoveCertificates+ },+ enableOperationId+ });diff --git a/backend/src/server/routes/v1/pki-sync-routers/index.ts b/backend/src/server/routes/v1/pki-sync-routers/index.tsindex c5ca67a3aa..9fefb3b4cd 100644--- a/backend/src/server/routes/v1/pki-sync-routers/index.ts+++ b/backend/src/server/routes/v1/pki-sync-routers/index.ts@@ -4,6 +4,7 @@ import { registerAwsCertificateManagerPkiSyncRouter } from "./aws-certificate-maimport { registerAwsSecretsManagerPkiSyncRouter } from "./aws-secrets-manager-pki-sync-router";import { registerAzureKeyVaultPkiSyncRouter } from "./azure-key-vault-pki-sync-router";import { registerChefPkiSyncRouter } from "./chef-pki-sync-router";+import { registerCloudflareCustomCertificatePkiSyncRouter } from "./cloudflare-custom-certificate-pki-sync-router";export * from "./pki-sync-router";@@ -14,5 +15,6 @@ export const PKI_SYNC_REGISTER_ROUTER_MAP: Record<[PkiSync.AzureKeyVault]: registerAzureKeyVaultPkiSyncRouter,[PkiSync.AwsCertificateManager]: registerAwsCertificateManagerPkiSyncRouter,[PkiSync.AwsSecretsManager]: registerAwsSecretsManagerPkiSyncRouter,- [PkiSync.Chef]: registerChefPkiSyncRouter+ [PkiSync.Chef]: registerChefPkiSyncRouter,+ [PkiSync.CloudflareCustomCertificate]: registerCloudflareCustomCertificatePkiSyncRouter};diff --git a/backend/src/services/certificate-authority/acme/dns-providers/cloudflare.ts b/backend/src/services/certificate-authority/acme/dns-providers/cloudflare.tsindex f4b12e657a..10de8c6c8a 100644--- a/backend/src/services/certificate-authority/acme/dns-providers/cloudflare.ts+++ b/backend/src/services/certificate-authority/acme/dns-providers/cloudflare.ts@@ -1,3 +1,4 @@+/* eslint-disable no-await-in-loop */import axios from "axios";import { request } from "@app/lib/config/request";@@ -57,46 +58,76 @@ export const cloudflareDeleteTxtRecord = async (credentials: { apiToken }} = connection;- try {- const listRecordsResponse = await request.get<{- result: { id: string; type: string; name: string; content: string }[];- }>(`${IntegrationUrls.CLOUDFLARE_API_URL}/client/v4/zones/${encodeURIComponent(hostedZoneId)}/dns_records`, {- headers: {- Authorization: `Bearer ${apiToken}`,- "Content-Type": "application/json",- Accept: "application/json"- },- params: {- type: "TXT",- name: domain,- content: value- }- });+ const maxRetries = 3;+ const initialDelay = 3000;+ let retryCount = 0;+ let lastError: Error | null = null;- const dnsRecords = listRecordsResponse.data?.result;+ while (retryCount < maxRetries) {+ try {+ const listRecordsResponse = await request.get<{+ result: { id: string; type: string; name: string; content: string }[];+ }>(`${IntegrationUrls.CLOUDFLARE_API_URL}/client/v4/zones/${encodeURIComponent(hostedZoneId)}/dns_records`, {+ headers: {+ Authorization: `Bearer ${apiToken}`,+ "Content-Type": "application/json",+ Accept: "application/json"+ },+ params: {+ type: "TXT",+ name: domain,+ content: value+ }+ });- if (Array.isArray(dnsRecords) && dnsRecords.length > 0) {- const recordToDelete = dnsRecords.find(- (record) => record.type === "TXT" && record.name === domain && record.content === value- );+ const dnsRecords = listRecordsResponse.data?.result;- if (recordToDelete) {- await request.delete(- `${IntegrationUrls.CLOUDFLARE_API_URL}/client/v4/zones/${encodeURIComponent(hostedZoneId)}/dns_records/${recordToDelete.id}`,- {- headers: {- Authorization: `Bearer ${apiToken}`,- "Content-Type": "application/json",- Accept: "application/json"- }- }+ if (Array.isArray(dnsRecords) && dnsRecords.length > 0) {+ const recordToDelete = dnsRecords.find(+ (record) => record.type === "TXT" && record.name === domain && record.content === value);++ if (recordToDelete) {+ await request.delete(+ `${IntegrationUrls.CLOUDFLARE_API_URL}/client/v4/zones/${encodeURIComponent(hostedZoneId)}/dns_records/${recordToDelete.id}`,+ {+ headers: {+ Authorization: `Bearer ${apiToken}`,+ "Content-Type": "application/json",+ Accept: "application/json"+ }+ }+ );+ // Successfully deleted the record+ return;+ }+ }++ // Record not found - might not have propagated yet, retry with backoff+ retryCount += 1;+ if (retryCount < maxRetries) {+ const delay = initialDelay * 2 ** (retryCount - 1);+ await new Promise((resolve) => {+ setTimeout(resolve, delay);+ });+ }+ } catch (error) {+ lastError = error as Error;+ retryCount += 1;++ if (retryCount < maxRetries) {+ const delay = initialDelay * 2 ** (retryCount - 1);+ await new Promise((resolve) => {+ setTimeout(resolve, delay);+ });}}- } catch (error) {- if (axios.isAxiosError(error)) {+ }++ if (lastError) {+ if (axios.isAxiosError(lastError)) {const firstErrorMessage = (- error.response?.data as {+ lastError.response?.data as {errors?: { message: string }[];})?.errors?.[0]?.message;@@ -104,6 +135,6 @@ export const cloudflareDeleteTxtRecord = async (throw new Error(firstErrorMessage);}}- throw error;+ throw lastError;}};diff --git a/backend/src/services/pki-sync/cloudflare-custom-certificate/cloudflare-custom-certificate-pki-sync-constants.ts b/backend/src/services/pki-sync/cloudflare-custom-certificate/cloudflare-custom-certificate-pki-sync-constants.tsnew file mode 100644index 0000000000..bd99677d7d--- /dev/null+++ b/backend/src/services/pki-sync/cloudflare-custom-certificate/cloudflare-custom-certificate-pki-sync-constants.ts@@ -0,0 +1,52 @@+import RE2 from "re2";++import { AppConnection } from "@app/services/app-connection/app-connection-enums";+import { PkiSync } from "@app/services/pki-sync/pki-sync-enums";++/**+ * Cloudflare Custom Certificate naming constraints for certificates+ */+export const CLOUDFLARE_CUSTOM_CERTIFICATE_NAMING = {+ /**+ * Regular expression pattern for valid Cloudflare certificate names+ * Certificate names can contain alphanumeric characters, hyphens, and underscores+ * Must be 1-255 characters long+ */+ NAME_PATTERN: new RE2("^[a-zA-Z0-9-_]{1,255}$"),++ /**+ * String of characters that are forbidden in Cloudflare certificate names+ */+ FORBIDDEN_CHARACTERS: "!@#$%^&*()+=[]{}|\\:;\"'<>,.?/~` ",++ /**+ * Maximum length for certificate names+ */+ MAX_NAME_LENGTH: 255,++ /**+ * Minimum length for certificate names+ */+ MIN_NAME_LENGTH: 1,++ /**+ * String representation of the allowed character pattern (for UI display)+ */+ ALLOWED_CHARACTER_PATTERN: "^[a-zA-Z0-9-_]{1,255}$"+} as const;++/**+ * Cloudflare Custom Certificate PKI Sync list option configuration+ */+export const CLOUDFLARE_CUSTOM_CERTIFICATE_PKI_SYNC_LIST_OPTION = {+ name: "Cloudflare Custom SSL Certificate" as const,+ connection: AppConnection.Cloudflare,+ destination: PkiSync.CloudflareCustomCertificate,+ canImportCertificates: false,+ canRemoveCertificates: true,+ defaultCertificateNameSchema: "Infisical-{{certificateId}}",+ forbiddenCharacters: CLOUDFLARE_CUSTOM_CERTIFICATE_NAMING.FORBIDDEN_CHARACTERS,+ allowedCharacterPattern: CLOUDFLARE_CUSTOM_CERTIFICATE_NAMING.ALLOWED_CHARACTER_PATTERN,+ maxCertificateNameLength: CLOUDFLARE_CUSTOM_CERTIFICATE_NAMING.MAX_NAME_LENGTH,+ minCertificateNameLength: CLOUDFLARE_CUSTOM_CERTIFICATE_NAMING.MIN_NAME_LENGTH+} as const;diff --git a/backend/src/services/pki-sync/cloudflare-custom-certificate/cloudflare-custom-certificate-pki-sync-fns.ts b/backend/src/services/pki-sync/cloudflare-custom-certificate/cloudflare-custom-certificate-pki-sync-fns.tsnew file mode 100644index 0000000000..7ec58d84e3--- /dev/null+++ b/backend/src/services/pki-sync/cloudflare-custom-certificate/cloudflare-custom-certificate-pki-sync-fns.ts@@ -0,0 +1,617 @@+/* eslint-disable no-await-in-loop */+import { AxiosError } from "axios";++import { TCertificateSyncs } from "@app/db/schemas";+import { request } from "@app/lib/config/request";+import { logger } from "@app/lib/logger";+import { TCertificateDALFactory } from "@app/services/certificate/certificate-dal";+import { TCertificateSyncDALFactory } from "@app/services/certificate-sync/certificate-sync-dal";+import { CertificateSyncStatus } from "@app/services/certificate-sync/certificate-sync-enums";+import { createConnectionQueue, RateLimitConfig } from "@app/services/connection-queue";+import { IntegrationUrls } from "@app/services/integration-auth/integration-list";+import { TCertificateMap } from "@app/services/pki-sync/pki-sync-types";++import { PkiSyncError } from "../pki-sync-errors";+import { TPkiSyncWithCredentials } from "../pki-sync-types";+import {+ CloudflareEdgeCertificate,+ TCloudflareCustomCertificatePkiSyncConfig+} from "./cloudflare-custom-certificate-pki-sync-types";++const CLOUDFLARE_RATE_LIMIT_CONFIG: RateLimitConfig = {+ MAX_CONCURRENT_REQUESTS: 5,+ BASE_DELAY: 1000,+ MAX_DELAY: 30000,+ MAX_RETRIES: 3,+ RATE_LIMIT_STATUS_CODES: [429, 503]+};++const cloudflareConnectionQueue = createConnectionQueue(CLOUDFLARE_RATE_LIMIT_CONFIG);++const { withRateLimitRetry, executeWithConcurrencyLimit } = cloudflareConnectionQueue;++type TCloudflareCustomCertificatePkiSyncFactoryDeps = {+ certificateSyncDAL: Pick<+ TCertificateSyncDALFactory,+ | "removeCertificates"+ | "addCertificates"+ | "findByPkiSyncAndCertificate"+ | "updateById"+ | "findByPkiSyncId"+ | "updateSyncStatus"+ >;+ certificateDAL: Pick<TCertificateDALFactory, "findById">;+};++const getCloudflareApiToken = (pkiSync: TPkiSyncWithCredentials) => {+ const credentials = pkiSync.connection.credentials as { apiToken: string; accountId: string };+ if (!credentials?.apiToken) {+ throw new PkiSyncError({+ message: "Cloudflare API token not found in connection credentials"+ });+ }+ return credentials.apiToken;+};++export const cloudflareCustomCertificatePkiSyncFactory = ({+ certificateSyncDAL,+ certificateDAL+}: TCloudflareCustomCertificatePkiSyncFactoryDeps) => {+ const listCloudflareEdgeCertificates = async (+ apiToken: string,+ zoneId: string,+ syncId = "unknown"+ ): Promise<Map<string, CloudflareEdgeCertificate>> => {+ const certificates = new Map<string, CloudflareEdgeCertificate>();++ let page = 1;+ const perPage = 50;+ let totalPages = 1;++ while (page <= totalPages) {+ const currentPage = page;+ const response = await withRateLimitRetry(+ () =>+ request.get<{+ result: CloudflareEdgeCertificate[];+ result_info: { page: number; per_page: number; total_pages: number; total_count: number };+ }>(`${IntegrationUrls.CLOUDFLARE_API_URL}/client/v4/zones/${zoneId}/custom_certificates`, {+ headers: {+ Authorization: `Bearer ${apiToken}`,+ "Content-Type": "application/json"+ },+ params: {+ page: currentPage,+ per_page: perPage+ }+ }),+ { operation: "list-edge-certificates", syncId }+ );++ for (const cert of response.data.result) {+ certificates.set(cert.id, cert);+ }++ totalPages = response.data.result_info.total_pages;+ page += 1;+ }++ return certificates;+ };++ const syncCertificates = async (pkiSync: TPkiSyncWithCredentials, certificateMap: TCertificateMap) => {+ const apiToken = getCloudflareApiToken(pkiSync);++ const destinationConfig = pkiSync.destinationConfig as TCloudflareCustomCertificatePkiSyncConfig;+ const { zoneId } = destinationConfig;++ if (!zoneId) {+ throw new PkiSyncError({+ message: "Cloudflare zone ID is required"+ });+ }++ const existingCloudflareIds: Set<string> = new Set();+ const edgeCerts = await listCloudflareEdgeCertificates(apiToken, zoneId, pkiSync.id);+ edgeCerts.forEach((_, id) => existingCloudflareIds.add(id));++ const existingSyncRecords = await certificateSyncDAL.findByPkiSyncId(pkiSync.id);+ const syncRecordsByCertId = new Map<string, TCertificateSyncs>();++ existingSyncRecords.forEach((record: TCertificateSyncs) => {+ if (record.certificateId) {+ syncRecordsByCertId.set(record.certificateId, record);+ }+ });++ const syncOptions = pkiSync.syncOptions as+ | {+ certificateNameSchema?: string;+ canRemoveCertificates?: boolean;+ }+ | undefined;+ const canRemoveCertificates = syncOptions?.canRemoveCertificates ?? true;++ const certificatesToUpload: {+ key: string;+ cert: string;+ privateKey: string;+ certificateChain?: string;+ caCertificate?: string;+ certificateId?: string;+ existingCloudflareId?: string;+ }[] = [];++ const skippedCertificates: Array<{ name: string; reason: string }> = [];+ const activeExternalIdentifiers = new Set<string>();++ for (const [certName, { cert, privateKey, certificateChain, caCertificate, certificateId }] of Object.entries(+ certificateMap+ )) {+ // Skip certificates that have already been renewed+ if (typeof certificateId === "string") {+ const certificate = await certificateDAL.findById(certificateId);+ if (certificate?.renewedByCertificateId) {+ skippedCertificates.push({+ name: certName,+ reason: "Certificate has been renewed and replaced by a newer certificate"+ });+ // eslint-disable-next-line no-continue+ continue;+ }+ }++ // Validate certificate content before attempting upload+ if (!cert || !cert.includes("-----BEGIN CERTIFICATE-----")) {+ skippedCertificates.push({+ name: certName,+ reason: "Certificate is missing or not in valid PEM format"+ });+ // eslint-disable-next-line no-continue+ continue;+ }++ if (!privateKey || !privateKey.includes("-----BEGIN")) {+ skippedCertificates.push({+ name: certName,+ reason: "Private key is missing or not in valid PEM format"+ });+ // eslint-disable-next-line no-continue+ continue;+ }++ let existingCloudflareId: string | undefined;++ if (typeof certificateId === "string") {+ const existingSyncRecord = syncRecordsByCertId.get(certificateId);++ if (+ existingSyncRecord?.externalIdentifier &&+ existingCloudflareIds.has(existingSyncRecord.externalIdentifier)+ ) {+ existingCloudflareId = existingSyncRecord.externalIdentifier;+ activeExternalIdentifiers.add(existingCloudflareId);+ }+ }++ certificatesToUpload.push({+ key: certName,+ cert,+ privateKey,+ certificateChain,+ caCertificate,+ certificateId,+ existingCloudflareId+ });+ }++ const certificatesToRemove: string[] = [];++ if (canRemoveCertificates) {+ existingSyncRecords.forEach((syncRecord) => {+ if (syncRecord.externalIdentifier && !activeExternalIdentifiers.has(syncRecord.externalIdentifier)) {+ if (existingCloudflareIds.has(syncRecord.externalIdentifier)) {+ certificatesToRemove.push(syncRecord.externalIdentifier);+ }+ }+ });+ }++ const uploadResults = await executeWithConcurrencyLimit(+ certificatesToUpload,+ async ({ key, cert, privateKey, certificateChain, caCertificate, certificateId, existingCloudflareId }) => {+ try {+ // Determine if this certificate was issued by a private CA.+ // When caCertificate is present, the cert was issued by an Infisical CA (private).+ // Private CAs require bundle_method "force" with the full chain including root,+ // while public CAs should use the configured bundle method without root (Cloudflare resolves the chain).+ const isPrivateCA = !!caCertificate;++ let fullCertificate: string;+ const bundleMethod = isPrivateCA ? "force" : "ubiquitous";++ if (isPrivateCA) {+ let chain = certificateChain?.trim() || "";+ const rootCa = caCertificate.trim();+ if (chain && !chain.includes(rootCa)) {+ chain = `${chain}\n${rootCa}`;+ } else if (!chain) {+ chain = rootCa;+ }+ fullCertificate = `${chain}\n${cert.trim()}`;+ } else if (bundleMethod === "force" && certificateChain) {+ fullCertificate = `${certificateChain.trim()}\n${cert.trim()}`;+ } else if (certificateChain) {+ fullCertificate = `${cert.trim()}\n${certificateChain.trim()}`;+ } else {+ fullCertificate = cert.trim();+ }++ let cloudflareCertId: string;++ if (existingCloudflareId) {+ const patchResponse = await withRateLimitRetry(+ () =>+ request.patch<{ result: CloudflareEdgeCertificate }>(+ `${IntegrationUrls.CLOUDFLARE_API_URL}/client/v4/zones/${zoneId}/custom_certificates/${existingCloudflareId}`,+ {+ certificate: fullCertificate,+ private_key: privateKey,+ bundle_method: bundleMethod+ },+ {+ headers: {+ Authorization: `Bearer ${apiToken}`,+ "Content-Type": "application/json"+ }+ }+ ),+ { operation: "patch-certificate", syncId: pkiSync.id }+ );+ cloudflareCertId = patchResponse.data.result.id;++ if (cloudflareCertId !== existingCloudflareId) {+ logger.info(+ {+ syncId: pkiSync.id,+ oldCertId: existingCloudflareId,+ newCertId: cloudflareCertId,+ certificateKey: key+ },+ "Cloudflare returned new certificate ID after PATCH (sni_custom behavior)"+ );+ }+ } else {+ const response = await withRateLimitRetry(+ () =>+ request.post<{ result: CloudflareEdgeCertificate }>(+ `${IntegrationUrls.CLOUDFLARE_API_URL}/client/v4/zones/${zoneId}/custom_certificates`,+ {+ certificate: fullCertificate,+ private_key: privateKey,+ bundle_method: bundleMethod,+ type: "sni_custom"+ },+ {+ headers: {+ Authorization: `Bearer ${apiToken}`,+ "Content-Type": "application/json"+ }+ }+ ),+ { operation: "post-certificate", syncId: pkiSync.id }+ );+ cloudflareCertId = response.data.result.id;+ }++ if (certificateId) {+ const existingCertSync = await certificateSyncDAL.findByPkiSyncAndCertificate(pkiSync.id, certificateId);+ if (existingCertSync) {+ await certificateSyncDAL.updateById(existingCertSync.id, {+ externalIdentifier: cloudflareCertId,+ syncStatus: CertificateSyncStatus.Succeeded,+ lastSyncedAt: new Date()+ });+ } else {+ await certificateSyncDAL.addCertificates(pkiSync.id, [+ {+ certificateId,+ externalIdentifier: cloudflareCertId+ }+ ]);+ }++ const currentCertificate = await certificateDAL.findById(certificateId);+ if (currentCertificate?.renewedFromCertificateId) {+ await certificateSyncDAL.removeCertificates(pkiSync.id, [currentCertificate.renewedFromCertificateId]);+ }+ }++ return { key, success: true, cloudflareCertId };+ } catch (error) {+ if (error instanceof AxiosError) {+ const errorMessage =+ error.response?.data && typeof error.response.data === "object" && "errors" in error.response.data+ ? (error.response.data as { errors?: Array<{ message?: string }> }).errors?.[0]?.message ||+ error.message+ : error.message;++ throw new PkiSyncError({+ message: `Failed to upload certificate ${key} to Cloudflare: ${errorMessage}`,+ cause: error,+ context: {+ certificateKey: key,+ statusCode: error.response?.status,+ responseData: error.response?.data+ }+ });+ }+ throw error;+ }+ },+ { operation: "upload-certificates", syncId: pkiSync.id }+ );++ const failedUploads = uploadResults.filter((result) => result.status === "rejected");+ const successfulUploads = uploadResults.filter((result) => result.status === "fulfilled" && result.value.success);++ let removedCertificates = 0;+ let failedRemovals = 0;++ if (certificatesToRemove.length > 0) {+ const removeResults = await executeWithConcurrencyLimit(+ certificatesToRemove,+ async (cloudflareCertId) => {+ try {+ await withRateLimitRetry(+ () =>+ request.delete(+ `${IntegrationUrls.CLOUDFLARE_API_URL}/client/v4/zones/${zoneId}/custom_certificates/${cloudflareCertId}`,+ {+ headers: {+ Authorization: `Bearer ${apiToken}`+ }+ }+ ),+ { operation: "delete-certificate", syncId: pkiSync.id }+ );++ return { id: cloudflareCertId, success: true };+ } catch (error) {+ if (error instanceof AxiosError && error.response?.status === 404) {+ return { id: cloudflareCertId, success: true, alreadyRemoved: true };+ }++ logger.error(+ { error, syncId: pkiSync.id, cloudflareCertId },+ "Failed to remove certificate from Cloudflare"+ );++ return { id: cloudflareCertId, success: false, error: error as Error };+ }+ },+ { operation: "remove-certificates", syncId: pkiSync.id }+ );++ const successfulRemovals = removeResults.filter(+ (result) => result.status === "fulfilled" && result.value.success+ );+ removedCertificates = successfulRemovals.length;+ failedRemovals = removeResults.length - removedCertificates;++ if (failedRemovals > 0) {+ logger.warn(+ {+ syncId: pkiSync.id,+ failedRemovals,+ successfulRemovals: removedCertificates+ },+ "Some certificates could not be removed from Cloudflare"+ );+ }+ }++ const details: {+ failedUploads?: Array<{ name: string; error: string }>;+ failedRemovals?: Array<{ name: string; error: string }>;+ skippedCertificates?: Array<{ name: string; reason: string }>;+ } = {};++ if (skippedCertificates.length > 0) {+ details.skippedCertificates = skippedCertificates;+ logger.info(+ {+ syncId: pkiSync.id,+ skippedCount: skippedCertificates.length,+ skippedCertificates+ },+ "Some certificates were skipped during Cloudflare sync"+ );+ }++ if (failedUploads.length > 0) {+ details.failedUploads = failedUploads.map((failure, index) => {+ const certificateName = certificatesToUpload[index]?.key || "unknown";+ let errorMessage = "Unknown error";++ if (failure.status === "rejected") {+ errorMessage = (failure.reason as Error)?.message || "Unknown error";+ }++ return {+ name: certificateName,+ error: errorMessage+ };+ });++ logger.error(+ {+ syncId: pkiSync.id,+ failedUploads: details.failedUploads,+ failedCount: failedUploads.length+ },+ "Some certificates failed to upload to Cloudflare"+ );+ }++ if (failedRemovals > 0) {+ const failedRemovalIds = certificatesToRemove.slice(-failedRemovals);+ details.failedRemovals = failedRemovalIds.map((certId) => ({+ name: certId,+ error: "Failed to remove from Cloudflare"+ }));+ }++ return {+ uploaded: successfulUploads.length,+ removed: removedCertificates,+ failedRemovals,+ skipped:+ skippedCertificates.length ++ (Object.keys(certificateMap).length - certificatesToUpload.length - skippedCertificates.length),+ details: Object.keys(details).length > 0 ? details : undefined+ };+ };++ const removeCertificates = async (+ pkiSync: TPkiSyncWithCredentials,+ certificateNames: string[],+ deps?: { certificateSyncDAL?: TCertificateSyncDALFactory; certificateMap?: TCertificateMap }+ ) => {+ const apiToken = getCloudflareApiToken(pkiSync);++ const destinationConfig = pkiSync.destinationConfig as TCloudflareCustomCertificatePkiSyncConfig;+ const { zoneId } = destinationConfig;++ const existingSyncRecords = await certificateSyncDAL.findByPkiSyncId(pkiSync.id);+ const cloudflareCertIdsToRemove: string[] = [];+ const certificateIdToCloudflareIdMap = new Map<string, string>();++ for (const certName of certificateNames) {+ if (deps?.certificateMap?.[certName]?.certificateId) {+ const { certificateId } = deps.certificateMap[certName];++ const syncRecord = existingSyncRecords.find((record) => record.certificateId === certificateId);++ if (syncRecord?.externalIdentifier && typeof certificateId === "string") {+ cloudflareCertIdsToRemove.push(syncRecord.externalIdentifier);+ certificateIdToCloudflareIdMap.set(certificateId, syncRecord.externalIdentifier);+ }+ }+ }++ if (cloudflareCertIdsToRemove.length === 0) {+ return {+ removed: 0,+ failed: 0,+ skipped: certificateNames.length+ };+ }++ const results = await executeWithConcurrencyLimit(+ cloudflareCertIdsToRemove,+ async (cloudflareCertId) => {+ try {+ await withRateLimitRetry(+ () =>+ request.delete(+ `${IntegrationUrls.CLOUDFLARE_API_URL}/client/v4/zones/${zoneId}/custom_certificates/${cloudflareCertId}`,+ {+ headers: {+ Authorization: `Bearer ${apiToken}`+ }+ }+ ),+ { operation: "delete-specific-certificate", syncId: pkiSync.id }+ );++ return { id: cloudflareCertId, success: true };+ } catch (error) {+ if (error instanceof AxiosError) {+ if (error.response?.status === 404) {+ return { id: cloudflareCertId, success: true, alreadyRemoved: true };+ }++ throw new PkiSyncError({+ message: `Failed to remove certificate ${cloudflareCertId} from Cloudflare`,+ cause: error,+ context: {+ cloudflareCertId,+ statusCode: error.response?.status,+ responseData: error.response?.data+ }+ });+ }+ throw error;+ }+ },+ { operation: "remove-specific-certificates", syncId: pkiSync.id }+ );++ const failedRemovals = results.filter((result) => result.status === "rejected");++ if (failedRemovals.length > 0 && deps?.certificateSyncDAL) {+ for (const failure of failedRemovals) {+ if (failure.status === "rejected") {+ const failedCloudflareId = cloudflareCertIdsToRemove[results.indexOf(failure)];++ const certificateId = Array.from(certificateIdToCloudflareIdMap.entries()).find(+ ([, cloudflareId]) => cloudflareId === failedCloudflareId+ )?.[0];++ if (certificateId) {+ const errorMessage = (failure.reason as Error)?.message || "Unknown error";+ await deps.certificateSyncDAL.updateSyncStatus(+ pkiSync.id,+ certificateId,+ CertificateSyncStatus.Failed,+ `Failed to remove from Cloudflare: ${errorMessage}`+ );+ }+ }+ }+ }++ const successfulRemovals = results.filter((result) => result.status === "fulfilled");+ if (successfulRemovals.length > 0) {+ const successfulCloudflareIds = new Set(successfulRemovals.map((_, index) => cloudflareCertIdsToRemove[index]));++ const certificateIdsToRemove = Array.from(certificateIdToCloudflareIdMap.entries())+ .filter(([, cloudflareId]) => successfulCloudflareIds.has(cloudflareId))+ .map(([certificateId]) => certificateId);++ if (certificateIdsToRemove.length > 0) {+ await certificateSyncDAL.removeCertificates(pkiSync.id, certificateIdsToRemove);+ }+ }++ if (failedRemovals.length > 0) {+ const failedReasons = failedRemovals.map((failure) => {+ if (failure.status === "rejected") {+ return (failure.reason as Error)?.message || "Unknown error";+ }+ return "Unknown error";+ });++ throw new PkiSyncError({+ message: `Failed to remove ${failedRemovals.length} certificate(s) from Cloudflare`,+ context: {+ failedReasons,+ totalCertificates: cloudflareCertIdsToRemove.length,+ failedCount: failedRemovals.length+ }+ });+ }++ return {+ removed: cloudflareCertIdsToRemove.length - failedRemovals.length,+ failed: failedRemovals.length,+ skipped: certificateNames.length - cloudflareCertIdsToRemove.length+ };+ };++ return {+ syncCertificates,+ removeCertificates+ };+};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.tsnew file mode 100644index 0000000000..f3089a87ff--- /dev/null+++ b/backend/src/services/pki-sync/cloudflare-custom-certificate/cloudflare-custom-certificate-pki-sync-schemas.ts@@ -0,0 +1,75 @@+import RE2 from "re2";+import { z } from "zod";++import { AppConnection } from "@app/services/app-connection/app-connection-enums";+import { PkiSync } from "@app/services/pki-sync/pki-sync-enums";+import { PkiSyncSchema } from "@app/services/pki-sync/pki-sync-schemas";++import { CLOUDFLARE_CUSTOM_CERTIFICATE_NAMING } from "./cloudflare-custom-certificate-pki-sync-constants";++export const CloudflareCustomCertificatePkiSyncConfigSchema = z.object({+ zoneId: z.string().min(1, "Zone ID is required")+});++// API-facing schema - only exposes user-configurable options+export const CloudflareCustomCertificatePkiSyncOptionsSchema = z.object({+ canRemoveCertificates: z.boolean().default(true),+ certificateNameSchema: z+ .string()+ .optional()+ .refine(+ (schema) => {+ if (!schema) return true;++ const testName = schema+ .replace(new RE2("\\{\\{certificateId\\}\\}", "g"), "")+ .replace(new RE2("\\{\\{environment\\}\\}", "g"), "");++ const hasForbiddenChars = CLOUDFLARE_CUSTOM_CERTIFICATE_NAMING.FORBIDDEN_CHARACTERS.split("").some((char) =>+ testName.includes(char)+ );++ return CLOUDFLARE_CUSTOM_CERTIFICATE_NAMING.NAME_PATTERN.test(testName) && !hasForbiddenChars;+ },+ {+ message:+ "Certificate name schema must result in names that contain only alphanumeric characters, hyphens (-), and underscores (_) and be 1-255 characters long when compiled for Cloudflare"+ }+ )+});++export const CloudflareCustomCertificatePkiSyncSchema = PkiSyncSchema.extend({+ destination: z.literal(PkiSync.CloudflareCustomCertificate),+ destinationConfig: CloudflareCustomCertificatePkiSyncConfigSchema,+ syncOptions: CloudflareCustomCertificatePkiSyncOptionsSchema+});++export const CreateCloudflareCustomCertificatePkiSyncSchema = z.object({+ name: z.string().trim().min(1).max(64),+ description: z.string().optional(),+ isAutoSyncEnabled: z.boolean().default(true),+ destinationConfig: CloudflareCustomCertificatePkiSyncConfigSchema,+ syncOptions: CloudflareCustomCertificatePkiSyncOptionsSchema.optional().default({}),+ subscriberId: z.string().nullish(),+ connectionId: z.string(),+ projectId: z.string().trim().min(1),+ certificateIds: z.array(z.string().uuid()).optional()+});++export const UpdateCloudflareCustomCertificatePkiSyncSchema = z.object({+ name: z.string().trim().min(1).max(64).optional(),+ description: z.string().optional(),+ isAutoSyncEnabled: z.boolean().optional(),+ destinationConfig: CloudflareCustomCertificatePkiSyncConfigSchema.optional(),+ syncOptions: CloudflareCustomCertificatePkiSyncOptionsSchema.optional(),+ subscriberId: z.string().nullish(),+ connectionId: z.string().optional()+});++export const CloudflareCustomCertificatePkiSyncListItemSchema = z.object({+ name: z.literal("Cloudflare Custom SSL Certificate"),+ connection: z.literal(AppConnection.Cloudflare),+ destination: z.literal(PkiSync.CloudflareCustomCertificate),+ canImportCertificates: z.literal(false),+ canRemoveCertificates: z.literal(true)+});diff --git a/backend/src/services/pki-sync/cloudflare-custom-certificate/cloudflare-custom-certificate-pki-sync-types.ts b/backend/src/services/pki-sync/cloudflare-custom-certificate/cloudflare-custom-certificate-pki-sync-types.tsnew file mode 100644index 0000000000..7f6f6a41a7--- /dev/null+++ b/backend/src/services/pki-sync/cloudflare-custom-certificate/cloudflare-custom-certificate-pki-sync-types.ts@@ -0,0 +1,36 @@+import { z } from "zod";++import { TCloudflareConnection } from "@app/services/app-connection/cloudflare/cloudflare-connection-types";++import {+ CloudflareCustomCertificatePkiSyncConfigSchema,+ CloudflareCustomCertificatePkiSyncSchema,+ CreateCloudflareCustomCertificatePkiSyncSchema,+ UpdateCloudflareCustomCertificatePkiSyncSchema+} from "./cloudflare-custom-certificate-pki-sync-schemas";++export type CloudflareEdgeCertificate = {+ id: string;+ hosts: string[];+ issuer: string;+ signature: string;+ status: string;+ bundle_method: string;+ zone_id: string;+ uploaded_on: string;+ modified_on: string;+ expires_on: string;+ priority: number;+};++export type TCloudflareCustomCertificatePkiSyncConfig = z.infer<typeof CloudflareCustomCertificatePkiSyncConfigSchema>;++export type TCloudflareCustomCertificatePkiSync = z.infer<typeof CloudflareCustomCertificatePkiSyncSchema>;++export type TCloudflareCustomCertificatePkiSyncInput = z.infer<typeof CreateCloudflareCustomCertificatePkiSyncSchema>;++export type TCloudflareCustomCertificatePkiSyncUpdate = z.infer<typeof UpdateCloudflareCustomCertificatePkiSyncSchema>;++export type TCloudflareCustomCertificatePkiSyncWithCredentials = TCloudflareCustomCertificatePkiSync & {+ connection: TCloudflareConnection;+};diff --git a/backend/src/services/pki-sync/cloudflare-custom-certificate/index.ts b/backend/src/services/pki-sync/cloudflare-custom-certificate/index.tsnew file mode 100644index 0000000000..e20c355f5d--- /dev/null+++ b/backend/src/services/pki-sync/cloudflare-custom-certificate/index.ts@@ -0,0 +1,4 @@+export * from "./cloudflare-custom-certificate-pki-sync-constants";+export * from "./cloudflare-custom-certificate-pki-sync-fns";+export * from "./cloudflare-custom-certificate-pki-sync-schemas";+export * from "./cloudflare-custom-certificate-pki-sync-types";diff --git a/backend/src/services/pki-sync/pki-sync-enums.ts b/backend/src/services/pki-sync/pki-sync-enums.tsindex bea444372a..a9045859c8 100644--- a/backend/src/services/pki-sync/pki-sync-enums.ts+++ b/backend/src/services/pki-sync/pki-sync-enums.ts@@ -2,7 +2,8 @@ export enum PkiSync {AzureKeyVault = "azure-key-vault",AwsCertificateManager = "aws-certificate-manager",AwsSecretsManager = "aws-secrets-manager",- Chef = "chef"+ Chef = "chef",+ CloudflareCustomCertificate = "cloudflare-custom-certificate"}export enum PkiSyncStatus {diff --git a/backend/src/services/pki-sync/pki-sync-fns.ts b/backend/src/services/pki-sync/pki-sync-fns.tsindex 169cb328f2..a40bda9adb 100644--- a/backend/src/services/pki-sync/pki-sync-fns.ts+++ b/backend/src/services/pki-sync/pki-sync-fns.ts@@ -16,6 +16,8 @@ import { AZURE_KEY_VAULT_PKI_SYNC_LIST_OPTION } from "./azure-key-vault/azure-keimport { azureKeyVaultPkiSyncFactory } from "./azure-key-vault/azure-key-vault-pki-sync-fns";import { chefPkiSyncFactory } from "./chef/chef-pki-sync-fns";import { CHEF_PKI_SYNC_LIST_OPTION } from "./chef/chef-pki-sync-list-constants";+import { CLOUDFLARE_CUSTOM_CERTIFICATE_PKI_SYNC_LIST_OPTION } from "./cloudflare-custom-certificate/cloudflare-custom-certificate-pki-sync-constants";+import { cloudflareCustomCertificatePkiSyncFactory } from "./cloudflare-custom-certificate/cloudflare-custom-certificate-pki-sync-fns";import { PkiSync } from "./pki-sync-enums";import { TCertificateMap, TPkiSyncWithCredentials } from "./pki-sync-types";@@ -25,7 +27,8 @@ const PKI_SYNC_LIST_OPTIONS = {[PkiSync.AzureKeyVault]: AZURE_KEY_VAULT_PKI_SYNC_LIST_OPTION,[PkiSync.AwsCertificateManager]: AWS_CERTIFICATE_MANAGER_PKI_SYNC_LIST_OPTION,[PkiSync.AwsSecretsManager]: AWS_SECRETS_MANAGER_PKI_SYNC_LIST_OPTION,- [PkiSync.Chef]: CHEF_PKI_SYNC_LIST_OPTION+ [PkiSync.Chef]: CHEF_PKI_SYNC_LIST_OPTION,+ [PkiSync.CloudflareCustomCertificate]: CLOUDFLARE_CUSTOM_CERTIFICATE_PKI_SYNC_LIST_OPTION};export const enterprisePkiSyncCheck = async (@@ -191,6 +194,11 @@ export const PkiSyncFns = {"Chef does not support importing certificates into Infisical (private keys cannot be extracted securely)");}+ case PkiSync.CloudflareCustomCertificate: {+ throw new Error(+ "Cloudflare Custom SSL Certificate does not support importing certificates into Infisical (private keys cannot be extracted)"+ );+ }default:throw new Error(`Unsupported PKI sync destination: ${String(pkiSync.destination)}`);}@@ -254,6 +262,14 @@ export const PkiSyncFns = {});return chefPkiSync.syncCertificates(pkiSync, certificateMap);}+ case PkiSync.CloudflareCustomCertificate: {+ checkPkiSyncDestination(pkiSync, PkiSync.CloudflareCustomCertificate as PkiSync);+ const cloudflareCustomCertificatePkiSync = cloudflareCustomCertificatePkiSyncFactory({+ certificateDAL: dependencies.certificateDAL,+ certificateSyncDAL: dependencies.certificateSyncDAL+ });+ return cloudflareCustomCertificatePkiSync.syncCertificates(pkiSync, certificateMap);+ }default:throw new Error(`Unsupported PKI sync destination: ${String(pkiSync.destination)}`);}@@ -320,6 +336,18 @@ export const PkiSyncFns = {});break;}+ case PkiSync.CloudflareCustomCertificate: {+ checkPkiSyncDestination(pkiSync, PkiSync.CloudflareCustomCertificate as PkiSync);+ const cloudflareCustomCertificatePkiSync = cloudflareCustomCertificatePkiSyncFactory({+ certificateDAL: dependencies.certificateDAL,+ certificateSyncDAL: dependencies.certificateSyncDAL+ });+ await cloudflareCustomCertificatePkiSync.removeCertificates(pkiSync, certificateNames, {+ certificateSyncDAL: dependencies.certificateSyncDAL,+ certificateMap: dependencies.certificateMap+ });+ break;+ }default:throw new Error(`Unsupported PKI sync destination: ${String(pkiSync.destination)}`);}diff --git a/backend/src/services/pki-sync/pki-sync-maps.ts b/backend/src/services/pki-sync/pki-sync-maps.tsindex a7edcbc113..4d2aa2fb32 100644--- a/backend/src/services/pki-sync/pki-sync-maps.ts+++ b/backend/src/services/pki-sync/pki-sync-maps.ts@@ -6,12 +6,14 @@ export const PKI_SYNC_NAME_MAP: Record<PkiSync, string> = {[PkiSync.AzureKeyVault]: "Azure Key Vault",[PkiSync.AwsCertificateManager]: "AWS Certificate Manager",[PkiSync.AwsSecretsManager]: "AWS Secrets Manager",- [PkiSync.Chef]: "Chef"+ [PkiSync.Chef]: "Chef",+ [PkiSync.CloudflareCustomCertificate]: "Cloudflare Custom SSL Certificate"};export const PKI_SYNC_CONNECTION_MAP: Record<PkiSync, AppConnection> = {[PkiSync.AzureKeyVault]: AppConnection.AzureKeyVault,[PkiSync.AwsCertificateManager]: AppConnection.AWS,[PkiSync.AwsSecretsManager]: AppConnection.AWS,- [PkiSync.Chef]: AppConnection.Chef+ [PkiSync.Chef]: AppConnection.Chef,+ [PkiSync.CloudflareCustomCertificate]: AppConnection.Cloudflare};diff --git a/docs/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/create.mdx b/docs/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/create.mdxnew file mode 100644index 0000000000..4c7a3619b5--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/create.mdx@@ -0,0 +1,4 @@+---+title: "Create Cloudflare Custom SSL PKI Sync"+openapi: "POST /api/v1/cert-manager/syncs/cloudflare-custom-certificate"+---diff --git a/docs/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/delete.mdx b/docs/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/delete.mdxnew file mode 100644index 0000000000..95ca008f33--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/delete.mdx@@ -0,0 +1,4 @@+---+title: "Delete Cloudflare Custom SSL PKI Sync"+openapi: "DELETE /api/v1/cert-manager/syncs/cloudflare-custom-certificate/{pkiSyncId}"+---diff --git a/docs/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/get-by-id.mdx b/docs/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/get-by-id.mdxnew file mode 100644index 0000000000..a43f625443--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/get-by-id.mdx@@ -0,0 +1,4 @@+---+title: "Get Cloudflare Custom SSL PKI Sync"+openapi: "GET /api/v1/cert-manager/syncs/cloudflare-custom-certificate/{pkiSyncId}"+---diff --git a/docs/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/list.mdx b/docs/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/list.mdxnew file mode 100644index 0000000000..1c71b08cad--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/list.mdx@@ -0,0 +1,4 @@+---+title: "List Cloudflare Custom SSL PKI Syncs"+openapi: "GET /api/v1/cert-manager/syncs/cloudflare-custom-certificate"+---diff --git a/docs/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/remove-certificates.mdx b/docs/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/remove-certificates.mdxnew file mode 100644index 0000000000..c5d304a5eb--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/remove-certificates.mdx@@ -0,0 +1,4 @@+---+title: "Remove Certificates from Cloudflare Custom SSL"+openapi: "POST /api/v1/cert-manager/syncs/cloudflare-custom-certificate/{pkiSyncId}/remove-certificates"+---diff --git a/docs/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/sync-certificates.mdx b/docs/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/sync-certificates.mdxnew file mode 100644index 0000000000..bd66a78083--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/sync-certificates.mdx@@ -0,0 +1,4 @@+---+title: "Sync Certificates to Cloudflare Custom SSL"+openapi: "POST /api/v1/cert-manager/syncs/cloudflare-custom-certificate/{pkiSyncId}/sync"+---diff --git a/docs/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/update.mdx b/docs/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/update.mdxnew file mode 100644index 0000000000..76a0fedce2--- /dev/null+++ b/docs/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/update.mdx@@ -0,0 +1,4 @@+---+title: "Update Cloudflare Custom SSL PKI Sync"+openapi: "PATCH /api/v1/cert-manager/syncs/cloudflare-custom-certificate/{pkiSyncId}"+---diff --git a/docs/docs.json b/docs/docs.jsonindex a63ebb8ce6..356cccba9a 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -739,7 +739,8 @@"documentation/platform/pki/certificate-syncs/aws-certificate-manager","documentation/platform/pki/certificate-syncs/aws-secrets-manager","documentation/platform/pki/certificate-syncs/azure-key-vault",- "documentation/platform/pki/certificate-syncs/chef"+ "documentation/platform/pki/certificate-syncs/chef",+ "documentation/platform/pki/certificate-syncs/cloudflare-custom-ssl"]},{@@ -2743,6 +2744,18 @@"api-reference/endpoints/pki/syncs/chef/sync-certificates","api-reference/endpoints/pki/syncs/chef/remove-certificates"]+ },+ {+ "group": "Cloudflare Custom SSL",+ "pages": [+ "api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/list",+ "api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/get-by-id",+ "api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/create",+ "api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/update",+ "api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/delete",+ "api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/sync-certificates",+ "api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/remove-certificates"+ ]}]}diff --git a/docs/documentation/platform/pki/certificate-syncs/cloudflare-custom-ssl.mdx b/docs/documentation/platform/pki/certificate-syncs/cloudflare-custom-ssl.mdxnew file mode 100644index 0000000000..8273ded166--- /dev/null+++ b/docs/documentation/platform/pki/certificate-syncs/cloudflare-custom-ssl.mdx@@ -0,0 +1,146 @@+---+title: "Cloudflare Custom SSL"+description: "Learn how to configure a Cloudflare Custom SSL Certificate Sync for Infisical PKI."+---++**Prerequisites:**++- Create a [Cloudflare Connection](/integrations/app-connections/cloudflare)++<Warning>+ **Custom Certificate Quota**: Cloudflare has a default quota of **one custom certificate per zone** on most plans.+ Enterprise plans may have higher quotas. If you attempt to sync more certificates than your quota allows,+ only one certificate will be successfully uploaded. Check your Cloudflare plan's certificate quota before+ configuring the sync, or contact Cloudflare to increase your quota.+</Warning>++<Tabs>+ <Tab title="Infisical UI">+ 1. Navigate to **Project** > **Integrations** > **Certificate Syncs** and press **Add Sync**.+ ++ 2. Select the **Cloudflare Custom SSL** option.+ ++ 3. Configure the **Destination** to where certificates should be deployed, then click **Next**.+ ++ - **Cloudflare Connection**: The Cloudflare Connection to authenticate with.+ - **Zone**: The Cloudflare zone (domain) where certificates should be uploaded.++ 4. Configure the **Sync Options** to specify how certificates should be synced, then click **Next**.+ ++ - **Enable Removal of Expired/Revoked Certificates**: If enabled, Infisical will remove certificates from the destination if they are no longer active in Infisical.+ - **Certificate Name Schema** (Optional): Customize how certificate names are generated. Must include `{{certificateId}}` as a placeholder. If not specified, defaults to `Infisical-{{certificateId}}`.+ - **Auto-Sync Enabled**: If enabled, certificates will automatically be synced when changes occur. Disable to enforce manual syncing only.++ 5. Configure the **Details** of your Cloudflare Custom SSL Certificate Sync, then click **Next**.+ ++ - **Name**: The name of your sync. Must be slug-friendly.+ - **Description**: An optional description for your sync.++ 6. Select which certificates should be synced to Cloudflare.+ ++ 7. Review your Cloudflare Custom SSL Certificate Sync configuration, then click **Create Sync**.+ ++ 8. If enabled, your Cloudflare Custom SSL Certificate Sync will begin syncing your certificates to the destination endpoint.+ + </Tab>+ <Tab title="API">+ To create a **Cloudflare Custom SSL Certificate Sync**, make an API request to the [Create Cloudflare Custom SSL Certificate Sync](/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/create) API endpoint.++ ### Sample request++ <Note>+ You can optionally specify `certificateIds` during sync creation to immediately add certificates to the sync.+ If not provided, you can add certificates later using the certificate management endpoints.+ </Note>++ ```bash Request+ curl --request POST \+ --url https://app.infisical.com/api/v1/cert-manager/syncs/cloudflare-custom-certificate \+ --header 'Authorization: Bearer <access-token>' \+ --header 'Content-Type: application/json' \+ --data '{+ "name": "my-cloudflare-cert-sync",+ "projectId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",+ "description": "an example certificate sync",+ "connectionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",+ "destination": "cloudflare-custom-certificate",+ "isAutoSyncEnabled": true,+ "certificateIds": [+ "550e8400-e29b-41d4-a716-446655440000",+ "660f1234-e29b-41d4-a716-446655440001"+ ],+ "syncOptions": {+ "canRemoveCertificates": true,+ "certificateNameSchema": "myapp-{{certificateId}}"+ },+ "destinationConfig": {+ "zoneId": "023e105f4ecef8ad9ca31a8372d0c353"+ }+ }'+ ```++ ### Sample response++ ```json Response+ {+ "pkiSync": {+ "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",+ "name": "my-cloudflare-cert-sync",+ "description": "an example certificate sync",+ "destination": "cloudflare-custom-certificate",+ "isAutoSyncEnabled": true,+ "destinationConfig": {+ "zoneId": "023e105f4ecef8ad9ca31a8372d0c353"+ },+ "syncOptions": {+ "canRemoveCertificates": true,+ "certificateNameSchema": "myapp-{{certificateId}}"+ },+ "projectId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",+ "connectionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",+ "createdAt": "2023-01-01T00:00:00.000Z",+ "updatedAt": "2023-01-01T00:00:00.000Z"+ }+ }+ ```+ </Tab>++</Tabs>++## Certificate Management++Your Cloudflare Custom SSL Certificate Sync will:++- **Automatic Deployment**: Deploy certificates in Infisical to Cloudflare as Custom SSL certificates.+- **Certificate Updates**: Update certificates in Cloudflare when renewals occur.+- **Expiration Handling**: Optionally remove expired certificates from Cloudflare (if enabled).+- **Chain Management**: Properly bundle certificate chains for optimal browser compatibility.++<Note>+ Cloudflare Custom SSL Certificate Syncs support both automatic and manual+ synchronization modes. When auto-sync is enabled, certificates are+ automatically deployed as they are issued or renewed.+</Note>++## Manual Certificate Sync++You can manually trigger certificate synchronization to Cloudflare using the sync certificates functionality. This is useful for:++- Initial setup when you have existing certificates to deploy+- One-time sync of specific certificates+- Testing certificate sync configurations+- Force sync after making changes++To manually sync certificates, use the [Sync Certificates](/api-reference/endpoints/pki/syncs/cloudflare-custom-certificate/sync-certificates) API endpoint or the manual sync option in the Infisical UI.++<Note>+ Cloudflare does not support importing certificates back into Infisical+ due to security limitations where private keys cannot be extracted from Cloudflare.+</Note>diff --git a/docs/documentation/platform/pki/certificate-syncs/overview.mdx b/docs/documentation/platform/pki/certificate-syncs/overview.mdxindex b72be71f90..d4e284f47a 100644--- a/docs/documentation/platform/pki/certificate-syncs/overview.mdx+++ b/docs/documentation/platform/pki/certificate-syncs/overview.mdx@@ -78,8 +78,8 @@ should be synced. Follow these steps to start syncing:desired project by specifying the following parameters via the UI or API:- <strong>Destination:</strong> The App Connection to utilize and the destination- endpoint to deploy certificates to such as [AWS Certificate Manager](/documentation/platform/pki/certificate-syncs/aws-certificate-manager)- or [Azure Key Vault](/documentation/platform/pki/certificate-syncs/azure-key-vault).+ endpoint to deploy certificates to such as [AWS Certificate Manager](/documentation/platform/pki/certificate-syncs/aws-certificate-manager),+ [Azure Key Vault](/documentation/platform/pki/certificate-syncs/azure-key-vault), or [Cloudflare Custom SSL](/documentation/platform/pki/certificate-syncs/cloudflare-custom-ssl).- <strong>Certificates:</strong> The certificates you wish to push to the destination.- <strong>Options:</strong> Customize how certificates should be synced, including:- Whether certificates should be removed from the destination when they expire.diff --git a/docs/images/app-connections/cloudflare/cloudflare-ssl-configure-permissions.png b/docs/images/app-connections/cloudflare/cloudflare-ssl-configure-permissions.pngnew file mode 100644index 0000000000..74529f0a17Binary files /dev/null and b/docs/images/app-connections/cloudflare/cloudflare-ssl-configure-permissions.png differdiff --git a/docs/images/platform/pki/certificate-syncs/cloudflare-custom-ssl/cloudflare-certificates.png b/docs/images/platform/pki/certificate-syncs/cloudflare-custom-ssl/cloudflare-certificates.pngnew file mode 100644index 0000000000..386ee28a5aBinary files /dev/null and b/docs/images/platform/pki/certificate-syncs/cloudflare-custom-ssl/cloudflare-certificates.png differdiff --git a/docs/images/platform/pki/certificate-syncs/cloudflare-custom-ssl/cloudflare-destination.png b/docs/images/platform/pki/certificate-syncs/cloudflare-custom-ssl/cloudflare-destination.pngnew file mode 100644index 0000000000..c3ba7cfda3Binary files /dev/null and b/docs/images/platform/pki/certificate-syncs/cloudflare-custom-ssl/cloudflare-destination.png differdiff --git a/docs/images/platform/pki/certificate-syncs/cloudflare-custom-ssl/cloudflare-details.png b/docs/images/platform/pki/certificate-syncs/cloudflare-custom-ssl/cloudflare-details.pngnew file mode 100644index 0000000000..ea747ed7fdBinary files /dev/null and b/docs/images/platform/pki/certificate-syncs/cloudflare-custom-ssl/cloudflare-details.png differdiff --git a/docs/images/platform/pki/certificate-syncs/cloudflare-custom-ssl/cloudflare-options.png b/docs/images/platform/pki/certificate-syncs/cloudflare-custom-ssl/cloudflare-options.pngnew file mode 100644index 0000000000..ab620d211fBinary files /dev/null and b/docs/images/platform/pki/certificate-syncs/cloudflare-custom-ssl/cloudflare-options.png differdiff --git a/docs/images/platform/pki/certificate-syncs/cloudflare-custom-ssl/cloudflare-review.png b/docs/images/platform/pki/certificate-syncs/cloudflare-custom-ssl/cloudflare-review.pngnew file mode 100644index 0000000000..713131a18cBinary files /dev/null and b/docs/images/platform/pki/certificate-syncs/cloudflare-custom-ssl/cloudflare-review.png differdiff --git a/docs/images/platform/pki/certificate-syncs/cloudflare-custom-ssl/cloudflare-synced.png b/docs/images/platform/pki/certificate-syncs/cloudflare-custom-ssl/cloudflare-synced.pngnew file mode 100644index 0000000000..5dfd881b19Binary files /dev/null and b/docs/images/platform/pki/certificate-syncs/cloudflare-custom-ssl/cloudflare-synced.png differdiff --git a/docs/images/platform/pki/certificate-syncs/cloudflare-custom-ssl/select-cloudflare-option.png b/docs/images/platform/pki/certificate-syncs/cloudflare-custom-ssl/select-cloudflare-option.pngnew file mode 100644index 0000000000..14be39f0b5Binary files /dev/null and b/docs/images/platform/pki/certificate-syncs/cloudflare-custom-ssl/select-cloudflare-option.png differdiff --git a/docs/integrations/app-connections/cloudflare.mdx b/docs/integrations/app-connections/cloudflare.mdxindex 33a9a992c7..9aee84772f 100644--- a/docs/integrations/app-connections/cloudflare.mdx+++ b/docs/integrations/app-connections/cloudflare.mdx@@ -51,15 +51,32 @@ Infisical supports connecting to Cloudflare using API tokens and Account ID for</AccordionGroup></Tab><Tab title="PKI">- Use the following permissions to grant Infisical access to verify certificates using DNS TXT records with ACME:+ <AccordionGroup>+ <Accordion title="ACME DNS Verification">+ Use the following permissions to grant Infisical access to verify certificates using DNS TXT records with ACME:++ ++ **Required Permissions:**+ - **Account** - **Account Settings** - **Read**+ - **Zone** - **DNS** - **Edit**++ Add these permissions to your API token and click **Continue to summary**, then **Create Token** to generate your API token.+ </Accordion>+ <Accordion title="Certificate Sync (Custom SSL)">+ Use the following permissions to grant Infisical access to sync certificates to Cloudflare as Custom SSL certificates:++ - + **Required Permissions:**+ - **Account** - **Account Settings** - **Read**+ - **Zone** - **SSL and Certificates** - **Edit**- **Required Permissions:**- - **Account** - **Account Settings** - **Read**- - **Zone** - **DNS** - **Edit**+ These permissions allow Infisical to upload, update, and delete custom SSL certificates in your Cloudflare zones.- Add these permissions to your API token and click **Continue to summary**, then **Create Token** to generate your API token.+ Add these permissions to your API token and click **Continue to summary**, then **Create Token** to generate your API token.+ </Accordion>+ </AccordionGroup></Tab></Tabs>diff --git a/frontend/src/components/pki-syncs/forms/CloudflareCustomCertificatePkiSyncFields.tsx b/frontend/src/components/pki-syncs/forms/CloudflareCustomCertificatePkiSyncFields.tsxnew file mode 100644index 0000000000..773a4a9056--- /dev/null+++ b/frontend/src/components/pki-syncs/forms/CloudflareCustomCertificatePkiSyncFields.tsx@@ -0,0 +1,63 @@+import { Controller, useFormContext } from "react-hook-form";+import { SingleValue } from "react-select";++import { FilterableSelect, FormControl } from "@app/components/v2";+import {+ TCloudflareZone,+ useCloudflareConnectionListZones+} from "@app/hooks/api/appConnections/cloudflare";+import { PkiSync } from "@app/hooks/api/pkiSyncs";++import { TPkiSyncForm } from "./schemas/pki-sync-schema";+import { PkiSyncConnectionField } from "./PkiSyncConnectionField";++export const CloudflareCustomCertificatePkiSyncFields = () => {+ const { control, watch, setValue } = useFormContext<+ TPkiSyncForm & { destination: PkiSync.CloudflareCustomCertificate }+ >();++ const connection = watch("connection");+ const connectionId = connection?.id;++ const { data: zones = [], isPending: isZonesLoading } = useCloudflareConnectionListZones(+ connectionId ?? "",+ {+ enabled: !!connectionId+ }+ );++ return (+ <>+ <PkiSyncConnectionField+ onChange={() => {+ setValue("destinationConfig.zoneId", "");+ }}+ />+ <Controller+ name="destinationConfig.zoneId"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ isError={Boolean(error)}+ errorText={error?.message}+ label="Zone"+ tooltipText="Select the Cloudflare zone (domain) where the custom SSL certificate will be uploaded."+ >+ <FilterableSelect+ isLoading={isZonesLoading && !!connectionId}+ isDisabled={!connectionId}+ value={zones.find((zone) => zone.id === value)}+ onChange={(option) => {+ onChange((option as SingleValue<TCloudflareZone>)?.id ?? "");+ }}+ options={zones}+ placeholder={connectionId ? "Select a zone..." : "Select a connection first"}+ getOptionLabel={(option) => option.name}+ getOptionValue={(option) => option.id}+ />+ </FormControl>+ )}+ />+ </>+ );+};diff --git a/frontend/src/components/pki-syncs/forms/PkiSyncDestinationFields.tsx b/frontend/src/components/pki-syncs/forms/PkiSyncDestinationFields.tsxindex 56514c262a..b39bcb893e 100644--- a/frontend/src/components/pki-syncs/forms/PkiSyncDestinationFields.tsx+++ b/frontend/src/components/pki-syncs/forms/PkiSyncDestinationFields.tsx@@ -7,6 +7,7 @@ import { AwsCertificateManagerPkiSyncFields } from "./AwsCertificateManagerPkiSyimport { AwsSecretsManagerPkiSyncFields } from "./AwsSecretsManagerPkiSyncFields";import { AzureKeyVaultPkiSyncFields } from "./AzureKeyVaultPkiSyncFields";import { ChefPkiSyncFields } from "./ChefPkiSyncFields";+import { CloudflareCustomCertificatePkiSyncFields } from "./CloudflareCustomCertificatePkiSyncFields";export const PkiSyncDestinationFields = () => {const { watch } = useFormContext<TPkiSyncForm>();@@ -22,6 +23,8 @@ export const PkiSyncDestinationFields = () => {return <AwsSecretsManagerPkiSyncFields />;case PkiSync.Chef:return <ChefPkiSyncFields />;+ case PkiSync.CloudflareCustomCertificate:+ return <CloudflareCustomCertificatePkiSyncFields />;default:return (<div className="flex items-center justify-center rounded-md border border-red-500 bg-red-100 p-4 text-red-700">diff --git a/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsx b/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsxindex b1763d2d86..ccf43ef3f3 100644--- a/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsx+++ b/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsx@@ -95,47 +95,49 @@ export const PkiSyncOptionsFields = ({ destination }: Props) => {)}/>- <Controller- control={control}- name="syncOptions.includeRootCa"- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl isError={Boolean(error)} errorText={error?.message}>- <Switch- className="bg-mineshaft-400/80 shadow-inner data-[state=checked]:bg-green/80"- id="include-root-ca"- thumbClassName="bg-mineshaft-800"- onCheckedChange={onChange}- isChecked={value}- >- <p>- Include Root CA in Certificate Chain{" "}- <Tooltip- className="max-w-md"- content={- <>- <p>- When enabled, the full certificate chain including the root CA will be- synced to the destination.- </p>- <p className="mt-4">- When disabled, the root CA will be excluded from the certificate chain- during sync operations, reducing the size of the synced certificate chain.- </p>- <p className="mt-4">- Most applications and services work correctly with intermediate certificates- only, as they can validate the trust chain up to a root CA they already- trust.- </p>- </>- }- >- <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />- </Tooltip>- </p>- </Switch>- </FormControl>- )}- />+ {currentDestination !== PkiSync.CloudflareCustomCertificate && (+ <Controller+ control={control}+ name="syncOptions.includeRootCa"+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl isError={Boolean(error)} errorText={error?.message}>+ <Switch+ className="bg-mineshaft-400/80 shadow-inner data-[state=checked]:bg-green/80"+ id="include-root-ca"+ thumbClassName="bg-mineshaft-800"+ onCheckedChange={onChange}+ isChecked={value}+ >+ <p>+ Include Root CA in Certificate Chain{" "}+ <Tooltip+ className="max-w-md"+ content={+ <>+ <p>+ When enabled, the full certificate chain including the root CA will be+ synced to the destination.+ </p>+ <p className="mt-4">+ When disabled, the root CA will be excluded from the certificate chain+ during sync operations, reducing the size of the synced certificate chain.+ </p>+ <p className="mt-4">+ Most applications and services work correctly with intermediate+ certificates only, as they can validate the trust chain up to a root CA+ they already trust.+ </p>+ </>+ }+ >+ <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />+ </Tooltip>+ </p>+ </Switch>+ </FormControl>+ )}+ />+ )}{currentDestination === PkiSync.AwsCertificateManager && (<Controllerdiff --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.tsnew file mode 100644index 0000000000..61fe8ee002--- /dev/null+++ b/frontend/src/components/pki-syncs/forms/schemas/cloudflare-custom-certificate-pki-sync-destination-schema.ts@@ -0,0 +1,71 @@+import { z } from "zod";++import { PkiSync } from "@app/hooks/api/pkiSyncs";++import { BasePkiSyncSchema } from "./base-pki-sync-schema";++// Only exposes user-configurable options+const CloudflareCustomCertificateSyncOptionsSchema = z.object({+ canRemoveCertificates: z.boolean().default(true),+ certificateNameSchema: z+ .string()+ .optional()+ .refine(+ (val) => {+ if (!val) return true;++ const allowedOptionalPlaceholders = ["{{environment}}"];++ const allowedPlaceholdersRegexPart = ["{{certificateId}}", ...allowedOptionalPlaceholders]+ .map((p) => p.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"))+ .join("|");++ const allowedContentRegex = new RegExp(+ `^([a-zA-Z0-9_\\-]|${allowedPlaceholdersRegexPart})*$`+ );+ const contentIsValid = allowedContentRegex.test(val);++ if (val.trim()) {+ const certificateIdRegex = /\{\{certificateId\}\}/;+ const certificateIdIsPresent = certificateIdRegex.test(val);+ return contentIsValid && certificateIdIsPresent;+ }++ return contentIsValid;+ },+ {+ message:+ "Certificate name schema must include exactly one {{certificateId}} placeholder. It can also include {{environment}} placeholders. Only alphanumeric characters (a-z, A-Z, 0-9), dashes (-), and underscores (_) are allowed besides the placeholders."+ }+ )+});++export const CloudflareCustomCertificatePkiSyncDestinationSchema = BasePkiSyncSchema(+ CloudflareCustomCertificateSyncOptionsSchema+).merge(+ z.object({+ destination: z.literal(PkiSync.CloudflareCustomCertificate),+ destinationConfig: z.object({+ zoneId: z.string().min(1, "Zone ID is required")+ })+ })+);++export const UpdateCloudflareCustomCertificatePkiSyncDestinationSchema =+ CloudflareCustomCertificatePkiSyncDestinationSchema.partial().merge(+ z.object({+ name: z+ .string()+ .trim()+ .min(1, "Name is required")+ .max(255, "Name must be less than 255 characters"),+ destination: z.literal(PkiSync.CloudflareCustomCertificate),+ connection: z.object({+ id: z.string().uuid("Invalid connection ID format"),+ name: z+ .string()+ .min(1, "Connection name is required")+ .max(255, "Connection name must be less than 255 characters")+ })+ })+ );diff --git a/frontend/src/components/pki-syncs/forms/schemas/pki-sync-schema.ts b/frontend/src/components/pki-syncs/forms/schemas/pki-sync-schema.tsindex 559fcdebc9..97d16b433d 100644--- a/frontend/src/components/pki-syncs/forms/schemas/pki-sync-schema.ts+++ b/frontend/src/components/pki-syncs/forms/schemas/pki-sync-schema.ts@@ -16,19 +16,25 @@ import {ChefPkiSyncDestinationSchema,UpdateChefPkiSyncDestinationSchema} from "./chef-pki-sync-destination-schema";+import {+ CloudflareCustomCertificatePkiSyncDestinationSchema,+ UpdateCloudflareCustomCertificatePkiSyncDestinationSchema+} from "./cloudflare-custom-certificate-pki-sync-destination-schema";const PkiSyncUnionSchema = z.discriminatedUnion("destination", [AzureKeyVaultPkiSyncDestinationSchema,AwsCertificateManagerPkiSyncDestinationSchema,AwsSecretsManagerPkiSyncDestinationSchema,- ChefPkiSyncDestinationSchema+ ChefPkiSyncDestinationSchema,+ CloudflareCustomCertificatePkiSyncDestinationSchema]);const UpdatePkiSyncUnionSchema = z.discriminatedUnion("destination", [UpdateAzureKeyVaultPkiSyncDestinationSchema,UpdateAwsCertificateManagerPkiSyncDestinationSchema,UpdateAwsSecretsManagerPkiSyncDestinationSchema,- UpdateChefPkiSyncDestinationSchema+ UpdateChefPkiSyncDestinationSchema,+ UpdateCloudflareCustomCertificatePkiSyncDestinationSchema]);export const PkiSyncFormSchema = PkiSyncUnionSchema;diff --git a/frontend/src/helpers/pkiSyncs.ts b/frontend/src/helpers/pkiSyncs.tsindex 471a4da059..ae5c02dc0f 100644--- a/frontend/src/helpers/pkiSyncs.ts+++ b/frontend/src/helpers/pkiSyncs.ts@@ -23,6 +23,10 @@ export const PKI_SYNC_MAP: Record<[PkiSync.Chef]: {name: "Chef",image: "Chef.png"+ },+ [PkiSync.CloudflareCustomCertificate]: {+ name: "Cloudflare Custom SSL",+ image: "Cloudflare.png"}};@@ -30,5 +34,6 @@ export const PKI_SYNC_CONNECTION_MAP: Record<PkiSync, AppConnection> = {[PkiSync.AzureKeyVault]: AppConnection.AzureKeyVault,[PkiSync.AwsCertificateManager]: AppConnection.AWS,[PkiSync.AwsSecretsManager]: AppConnection.AWS,- [PkiSync.Chef]: AppConnection.Chef+ [PkiSync.Chef]: AppConnection.Chef,+ [PkiSync.CloudflareCustomCertificate]: AppConnection.Cloudflare};diff --git a/frontend/src/hooks/api/pkiSyncs/enums.ts b/frontend/src/hooks/api/pkiSyncs/enums.tsindex ee9af0c4f0..6a222640f0 100644--- a/frontend/src/hooks/api/pkiSyncs/enums.ts+++ b/frontend/src/hooks/api/pkiSyncs/enums.ts@@ -2,7 +2,8 @@ export enum PkiSync {AzureKeyVault = "azure-key-vault",AwsCertificateManager = "aws-certificate-manager",AwsSecretsManager = "aws-secrets-manager",- Chef = "chef"+ Chef = "chef",+ CloudflareCustomCertificate = "cloudflare-custom-certificate"}export enum PkiSyncStatus {diff --git a/frontend/src/hooks/api/pkiSyncs/types/cloudflare-custom-certificate-sync.ts b/frontend/src/hooks/api/pkiSyncs/types/cloudflare-custom-certificate-sync.tsnew file mode 100644index 0000000000..a79fad36be--- /dev/null+++ b/frontend/src/hooks/api/pkiSyncs/types/cloudflare-custom-certificate-sync.ts@@ -0,0 +1,16 @@+import { AppConnection } from "@app/hooks/api/appConnections/enums";++import { PkiSync } from "../enums";+import { TRootPkiSync } from "./common";++export type TCloudflareCustomCertificatePkiSync = TRootPkiSync & {+ destination: PkiSync.CloudflareCustomCertificate;+ destinationConfig: {+ zoneId: string;+ };+ connection: {+ app: AppConnection.Cloudflare;+ name: string;+ id: string;+ };+};diff --git a/frontend/src/hooks/api/pkiSyncs/types/index.ts b/frontend/src/hooks/api/pkiSyncs/types/index.tsindex 53b910bf79..da21d317f6 100644--- a/frontend/src/hooks/api/pkiSyncs/types/index.ts+++ b/frontend/src/hooks/api/pkiSyncs/types/index.ts@@ -4,6 +4,7 @@ import { TAwsCertificateManagerPkiSync } from "./aws-certificate-manager-sync";import { TAwsSecretsManagerPkiSync } from "./aws-secrets-manager-sync";import { TAzureKeyVaultPkiSync } from "./azure-key-vault-sync";import { TChefPkiSync } from "./chef-sync";+import { TCloudflareCustomCertificatePkiSync } from "./cloudflare-custom-certificate-sync";export type TPkiSyncOption = {name: string;@@ -22,7 +23,8 @@ export type TPkiSync =| TAzureKeyVaultPkiSync| TAwsCertificateManagerPkiSync| TAwsSecretsManagerPkiSync- | TChefPkiSync;+ | TChefPkiSync+ | TCloudflareCustomCertificatePkiSync;export type TListPkiSyncs = { pkiSyncs: TPkiSync[] };@@ -61,6 +63,7 @@ export type TCreatePkiSyncDTO = TCreatePkiSyncDTOBase & {vaultBaseUrl?: string;region?: string;dataBagName?: string;+ zoneId?: string;};};@@ -97,4 +100,5 @@ export * from "./aws-certificate-manager-sync";export * from "./aws-secrets-manager-sync";export * from "./azure-key-vault-sync";export * from "./chef-sync";+export * from "./cloudflare-custom-certificate-sync";export * from "./common";