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
Address PR comments
Carlos Monastyrskie7ebe77e9106
diff --git a/backend/src/lib/gateway-v2/winrm-rpc.ts b/backend/src/lib/gateway-v2/winrm-rpc.tsindex 46ec1cddd0..ea69f2d22e 100644--- a/backend/src/lib/gateway-v2/winrm-rpc.ts+++ b/backend/src/lib/gateway-v2/winrm-rpc.ts@@ -2,7 +2,11 @@ import http from "node:http";import { logger } from "@app/lib/logger";-export type WinRmRpcEndpoint = "/v1/test" | "/v1/deliver" | "/v1/remove";+export enum WinRmRpcEndpoint {+ Test = "/v1/test",+ DeliverFiles = "/v1/deliver",+ RemoveFiles = "/v1/remove"+}export type WinRmTransportParams = {useHttps?: boolean;diff --git a/backend/src/services/app-connection/ssh/ssh-connection-fns.ts b/backend/src/services/app-connection/ssh/ssh-connection-fns.tsindex 79165588ce..953ef9bbd8 100644--- a/backend/src/services/app-connection/ssh/ssh-connection-fns.ts+++ b/backend/src/services/app-connection/ssh/ssh-connection-fns.ts@@ -168,7 +168,7 @@ export const executeWithPotentialGateway = async <T>(const { gatewayId: directGatewayId, gatewayPoolId, credentials } = config;if (gatewayPoolId && !gatewayPoolService) {- throw new BadRequestError({+ throw new InternalServerError({message: "Pool-backed connections require gatewayPoolService at the call site"});}@@ -179,7 +179,9 @@ export const executeWithPotentialGateway = async <T>(if (gatewayId) {if (!gatewayV2Service) {- throw new BadRequestError({ message: "Gateway-backed connections require gatewayV2Service at the call site" });+ throw new InternalServerError({+ message: "Gateway-backed connections require gatewayV2Service at the call site"+ });}await blockLocalAndPrivateIpAddresses(`ssh://${credentials.host}:${credentials.port}`, true);diff --git a/backend/src/services/app-connection/winrm/winrm-connection-fns.ts b/backend/src/services/app-connection/winrm/winrm-connection-fns.tsindex e84a14bbb2..16e4de63fe 100644--- a/backend/src/services/app-connection/winrm/winrm-connection-fns.ts+++ b/backend/src/services/app-connection/winrm/winrm-connection-fns.ts@@ -1,7 +1,7 @@import { TGatewayServiceFactory } from "@app/ee/services/gateway/gateway-service";import { TGatewayPoolServiceFactory } from "@app/ee/services/gateway-pool/gateway-pool-service";import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";-import { BadRequestError } from "@app/lib/errors";+import { BadRequestError, InternalServerError } from "@app/lib/errors";import { GatewayProxyProtocol } from "@app/lib/gateway/types";import { withGatewayV2Proxy } from "@app/lib/gateway-v2/gateway-v2";import { callWinRmEndpoint, WinRmRpcEndpoint } from "@app/lib/gateway-v2/winrm-rpc";@@ -52,7 +52,7 @@ export const executeWinRMGatewayOperation = async <T>(const { gatewayV2Service, gatewayPoolService } = deps;if (args.gatewayPoolId && !gatewayPoolService) {- throw new BadRequestError({ message: "Pool-backed connections require gatewayPoolService at the call site" });+ throw new InternalServerError({ message: "Pool-backed connections require gatewayPoolService at the call site" });}const gatewayId =@@ -123,7 +123,7 @@ export const validateWinRMConnectionCredentials = async (gatewayId: config.gatewayId,gatewayPoolId: config.gatewayPoolId,credentials: config.credentials,- endpoint: "/v1/test"+ endpoint: WinRmRpcEndpoint.Test},{ gatewayV2Service });diff --git a/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-fns.ts b/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-fns.tsindex bc8442d2b0..39939883ea 100644--- a/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-fns.ts+++ b/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-fns.ts@@ -16,7 +16,7 @@ import { TCertificateSyncDALFactory } from "@app/services/certificate-sync/certiimport { TSyncMetadata } from "@app/services/certificate-sync/certificate-sync-schemas";import { PkiSyncError } from "../pki-sync-errors";-import { exportCertificateForSync, PkiSyncExportFormat } from "../pki-sync-export-fns";+import { exportCertificateForSync, PemCertificateExtension, PkiSyncExportFormat } from "../pki-sync-export-fns";import { TCertificateMap, TPkiSyncSyncResult, TPkiSyncWithCredentials } from "../pki-sync-types";import { TLinuxServerPkiSyncConfig } from "./linux-server-pki-sync-types";@@ -32,8 +32,14 @@ type TLinuxServerPkiSyncFactoryDeps = {type TLinuxServerSyncOptions = {certificateNameSchema?: string;exportFormat?: PkiSyncExportFormat;+ pemCertificateExtension?: PemCertificateExtension;+ combineCertificateChain?: boolean;includePrivateKey?: boolean;canRemoveCertificates?: boolean;+ fileMode?: string;+ privateKeyFileMode?: string;+ owner?: string;+ group?: string;};const buildSshConfig = (pkiSync: TPkiSyncWithCredentials): TSshConnectionConfig => {@@ -70,6 +76,48 @@ const openSftp = (client: Client) =>client.sftp((err, sftp) => (err ? reject(err) : resolve(sftp)));});+// Parses an octal file-mode string (e.g. "0640" or "640") into a number, falling back when unset/invalid.+const parseFileMode = (mode: string | undefined, fallback: number): number => {+ if (!mode) return fallback;+ const parsed = Number.parseInt(mode, 8);+ return Number.isNaN(parsed) ? fallback : parsed;+};++// Escapes a value for a POSIX single-quoted shell literal so a path is safe to embed in a command.+const singleQuote = (value: string): string => `'${value.replace(/'/g, "'\\''")}'`;++const applyOwnership = (+ client: Client,+ owner: string | undefined,+ group: string | undefined,+ filePath: string+): Promise<void> =>+ new Promise<void>((resolve, reject) => {+ if (!owner && !group) {+ resolve();+ return;+ }+ const spec = `${owner ?? ""}${group ? `:${group}` : ""}`;+ const target = singleQuote(filePath);+ const command = `chown ${spec} -- ${target} 2>/dev/null || sudo -n chown ${spec} -- ${target}`;+ client.exec(command, (err, stream) => {+ if (err) {+ reject(err);+ return;+ }+ let stderr = "";+ stream+ .on("close", (code: number) => {+ if (code === 0) resolve();+ else reject(new Error(stderr.trim() || `chown exited with code ${code}`));+ })+ .stderr.on("data", (chunk: Buffer) => {+ stderr += chunk.toString();+ });+ stream.on("data", () => {});+ });+ });+const writeFileAtomic = (sftp: SFTPWrapper, filePath: string, content: Buffer, mode: number): Promise<void> => {// A per-write random suffix keeps concurrent syncs (e.g. a manual trigger overlapping an auto-sync)// from sharing one temp path and orphaning it: OpenSSH rename is not atomic-overwrite, so we@@ -185,6 +233,8 @@ export const linuxServerPkiSyncFactory = ({const format = options.exportFormat ?? PkiSyncExportFormat.Pem;const includePrivateKey = options.includePrivateKey ?? true;const canRemoveCertificates = options.canRemoveCertificates ?? false;+ const privateKeyMode = parseFileMode(options.privateKeyFileMode, PRIVATE_KEY_FILE_MODE);+ const certificateMode = parseFileMode(options.fileMode, CERTIFICATE_FILE_MODE);const exportPassword = pkiSync.syncCredentials?.exportPassword;const failedUploads: Array<{ name: string; error: string }> = [];@@ -233,19 +283,16 @@ export const linuxServerPkiSyncFactory = ({privateKey,includePrivateKey,password: exportPassword,- alias: baseName+ alias: baseName,+ pemCertificateExtension: options.pemCertificateExtension,+ combineCertificateChain: options.combineCertificateChain});const writtenPaths: string[] = [];for (const file of files) {const filePath = path.posix.join(config.destinationPath, `${baseName}${file.suffix}`);try {- await writeFileAtomic(- sftp,- filePath,- file.content,- file.isPrivateKey ? PRIVATE_KEY_FILE_MODE : CERTIFICATE_FILE_MODE- );+ await writeFileAtomic(sftp, filePath, file.content, file.isPrivateKey ? privateKeyMode : certificateMode);} catch (writeErr) {const msg = (writeErr as Error)?.message ?? "";if (NO_SUCH_FILE_ERROR.test(msg)) {@@ -255,6 +302,7 @@ export const linuxServerPkiSyncFactory = ({}throw writeErr;}+ await applyOwnership(client, options.owner, options.group, filePath);writtenPaths.push(filePath);deliveredPaths.add(filePath);}diff --git a/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-schemas.ts b/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-schemas.tsindex c99894a8bf..621190fa98 100644--- a/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-schemas.ts+++ b/backend/src/services/pki-sync/linux-server/linux-server-pki-sync-schemas.ts@@ -1,16 +1,19 @@import RE2 from "re2";import { z } from "zod";-import { openApiHidden } from "@app/server/lib/schemas";import { AppConnection } from "@app/services/app-connection/app-connection-enums";import { buildCertificateNameSchemaTestName } from "@app/services/pki-sync/pki-sync-certificate-name-fns";import { PkiSync } from "@app/services/pki-sync/pki-sync-enums";-import { PkiSyncExportFormat } from "@app/services/pki-sync/pki-sync-export-fns";+import { PemCertificateExtension, PkiSyncExportFormat } from "@app/services/pki-sync/pki-sync-export-fns";import { PkiSyncSchema } from "@app/services/pki-sync/pki-sync-schemas";import { LINUX_SERVER_NAMING } from "./linux-server-pki-sync-constants";const PATH_TRAVERSAL = new RE2("(^|/)\\.\\.(/|$)");+// A 3- or 4-digit octal file mode, optionally with a leading zero (e.g. "640", "0640").+const OCTAL_FILE_MODE = new RE2("^0?[0-7]{3}$");+// A POSIX user/group name. Restricted so it is safe to embed in the chown command run on the server.+const POSIX_NAME = new RE2("^[a-z_][a-z0-9_-]*\\$?$", "i");export const LinuxServerPkiSyncConfigSchema = z.object({destinationPath: z@@ -27,6 +30,32 @@ export const LinuxServerPkiSyncOptionsSchema = z.object({includeRootCa: z.boolean().default(false),includePrivateKey: z.boolean().default(true),exportFormat: z.nativeEnum(PkiSyncExportFormat).default(PkiSyncExportFormat.Pem),+ pemCertificateExtension: z.nativeEnum(PemCertificateExtension).default(PemCertificateExtension.Pem),+ combineCertificateChain: z.boolean().default(false),+ fileMode: z+ .string()+ .trim()+ .refine((m) => OCTAL_FILE_MODE.test(m), { message: "File mode must be a 3-digit octal value (for example 644)" })+ .optional(),+ privateKeyFileMode: z+ .string()+ .trim()+ .refine((m) => OCTAL_FILE_MODE.test(m), {+ message: "Private key file mode must be a 3-digit octal value (for example 600)"+ })+ .optional(),+ owner: z+ .string()+ .trim()+ .max(32)+ .refine((v) => POSIX_NAME.test(v), { message: "Owner must be a valid Linux user name" })+ .optional(),+ group: z+ .string()+ .trim()+ .max(32)+ .refine((v) => POSIX_NAME.test(v), { message: "Group must be a valid Linux group name" })+ .optional(),certificateNameSchema: z.string().trim()@@ -68,7 +97,6 @@ export const CreateLinuxServerPkiSyncSchema = zcredentials: LinuxServerPkiSyncCredentialsSchema.optional(),subscriberId: z.string().nullish(),connectionId: z.string(),- projectId: z.string().trim().min(1).optional().describe(openApiHidden()),applicationId: z.string().uuid().optional(),certificateIds: z.array(z.string().uuid()).optional()})diff --git a/backend/src/services/pki-sync/pki-sync-export-fns.ts b/backend/src/services/pki-sync/pki-sync-export-fns.tsindex b8a30db9c7..a2689ca3f6 100644--- a/backend/src/services/pki-sync/pki-sync-export-fns.ts+++ b/backend/src/services/pki-sync/pki-sync-export-fns.ts@@ -5,6 +5,11 @@ export enum PkiSyncExportFormat {Pkcs12 = "pkcs12"}+export enum PemCertificateExtension {+ Pem = "pem",+ Crt = "crt"+}+export type TExportedCertificateFile = {suffix: string;content: Buffer;@@ -21,12 +26,18 @@ export type TExportCertificateForSyncParams = {password?: string;// Friendly name / alias used inside a PKCS#12 keystore.alias: string;+ // PEM only: the extension for the certificate and chain files. Defaults to ".pem".+ pemCertificateExtension?: PemCertificateExtension;+ // PEM only: when true, the certificate file holds the leaf certificate followed by the chain (a+ // "full chain" file, as nginx expects) and no separate chain file is written. Defaults to false.+ combineCertificateChain?: boolean;};/*** Packages a certificate for delivery to a server. The extension is decided here from the format,* never from the caller's name schema (the schema only provides the base name):- * - PEM -> "<base>.pem" (cert), "<base>.chain.pem" (chain), "<base>.key" (key, when included)+ * - PEM -> "<base>.<pem|crt>" (cert), "<base>.chain.<pem|crt>" (chain), "<base>.key" (key, when included)+ * - PEM (combined chain) -> "<base>.<pem|crt>" (leaf + chain), "<base>.key" (key, when included)* - PKCS#12 -> "<base>.pfx" (cert + chain + key, password-protected)** The caller is responsible for deciding whether the private key is available and whether it is@@ -40,7 +51,9 @@ export const exportCertificateForSync = ({privateKey,includePrivateKey,password,- alias+ alias,+ pemCertificateExtension,+ combineCertificateChain}: TExportCertificateForSyncParams): Promise<TExportedCertificateFile[]> | TExportedCertificateFile[] => {if (format === PkiSyncExportFormat.Pkcs12) {return generatePkcs12FromCertificate({@@ -52,10 +65,20 @@ export const exportCertificateForSync = ({}).then((pfx) => [{ suffix: ".pfx", content: pfx, isPrivateKey: true }]);}- const files: TExportedCertificateFile[] = [{ suffix: ".pem", content: Buffer.from(certificate, "utf8") }];- if (certificateChain) {- files.push({ suffix: ".chain.pem", content: Buffer.from(certificateChain, "utf8") });+ const certExtension = pemCertificateExtension ?? PemCertificateExtension.Pem;+ const files: TExportedCertificateFile[] = [];++ if (combineCertificateChain && certificateChain) {+ // Full chain: leaf certificate followed by the chain, in one file, no separate chain file.+ const fullChain = `${certificate.trim()}\n${certificateChain.trim()}\n`;+ files.push({ suffix: `.${certExtension}`, content: Buffer.from(fullChain, "utf8") });+ } else {+ files.push({ suffix: `.${certExtension}`, content: Buffer.from(certificate, "utf8") });+ if (certificateChain) {+ files.push({ suffix: `.chain.${certExtension}`, content: Buffer.from(certificateChain, "utf8") });+ }}+if (includePrivateKey && privateKey) {files.push({ suffix: ".key", content: Buffer.from(privateKey, "utf8"), isPrivateKey: true });}diff --git a/backend/src/services/pki-sync/pki-sync-queue.ts b/backend/src/services/pki-sync/pki-sync-queue.tsindex ea74667dc9..bd6710ca59 100644--- a/backend/src/services/pki-sync/pki-sync-queue.ts+++ b/backend/src/services/pki-sync/pki-sync-queue.ts@@ -432,6 +432,7 @@ export const pkiSyncQueueFactory = ({);let isSynced = false;+ let certSyncFailureCount = 0;let syncMessage: string | null = null;let isFinalAttempt = job.attemptsStarted === job.opts.attempts;@@ -577,6 +578,49 @@ export const pkiSyncQueueFactory = ({await certificateSyncDAL.bulkUpdateSyncStatus(postSyncUpdates);}+ const failedCertificateCount = postSyncUpdates.filter(+ (update) => update.status === CertificateSyncStatus.Failed+ ).length;+ certSyncFailureCount = failedCertificateCount + (syncResult.failedRemovals ?? 0);++ const processedCertificateIds = new Set(Array.from(certificateMetadata.values()).map((meta) => meta.id));+ const nonTerminalStatuses = new Set<string>([+ CertificateSyncStatus.Pending,+ CertificateSyncStatus.Running,+ CertificateSyncStatus.Syncing+ ]);+ const trackedRecords = await certificateSyncDAL.findByPkiSyncId(pkiSync.id);+ const strandedCertificateIds = trackedRecords+ .filter(+ (record) =>+ record.certificateId &&+ !processedCertificateIds.has(record.certificateId) &&+ nonTerminalStatuses.has(record.syncStatus ?? "")+ )+ .map((record) => record.certificateId)+ .filter((id): id is string => typeof id === "string");+ if (strandedCertificateIds.length > 0) {+ const stillEligible = (await certificateDAL.findActiveCertificatesByIds(strandedCertificateIds)).filter(+ (cert) => !cert.renewedByCertificateId+ );+ if (stillEligible.length > 0) {+ await certificateSyncDAL.bulkUpdateSyncStatus(+ stillEligible.map((cert) => ({+ pkiSyncId: pkiSync.id,+ certificateId: cert.id,+ status: CertificateSyncStatus.Failed,+ message:+ "Certificate could not be prepared for syncing (its data could not be loaded, or it resolved to the same file name as another certificate)"+ }))+ );+ certSyncFailureCount += stillEligible.length;+ }+ }++ if (certSyncFailureCount > 0) {+ syncMessage = `${certSyncFailureCount} certificate(s) failed to sync to the destination`;+ }+isSynced = true;} catch (err) {logger.error(@@ -605,7 +649,8 @@ export const pkiSyncQueueFactory = ({}} finally {const ranAt = new Date();- const syncStatus = isSynced ? PkiSyncStatus.Succeeded : PkiSyncStatus.Failed;+ const fullySynced = isSynced && certSyncFailureCount === 0;+ const syncStatus = fullySynced ? PkiSyncStatus.Succeeded : PkiSyncStatus.Failed;await auditLogService.createAuditLog({projectId: pkiSync.projectId,@@ -631,7 +676,7 @@ export const pkiSyncQueueFactory = ({syncStatus,lastSyncJobId: job.id,lastSyncMessage: syncMessage,- lastSyncedAt: isSynced ? ranAt : undefined+ lastSyncedAt: fullySynced ? ranAt : undefined});await telemetryService.sendPostHogEvents({@@ -641,7 +686,7 @@ export const pkiSyncQueueFactory = ({properties: {orgId: pkiSync.connection.orgId,destination: pkiSync.destination,- success: isSynced+ success: fullySynced}});}diff --git a/backend/src/services/pki-sync/windows-server/windows-server-pki-sync-fns.ts b/backend/src/services/pki-sync/windows-server/windows-server-pki-sync-fns.tsindex 758479b34d..c7d7062903 100644--- a/backend/src/services/pki-sync/windows-server/windows-server-pki-sync-fns.ts+++ b/backend/src/services/pki-sync/windows-server/windows-server-pki-sync-fns.ts@@ -3,11 +3,12 @@ import RE2 from "re2";import { TGatewayPoolServiceFactory } from "@app/ee/services/gateway-pool/gateway-pool-service";import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";+import { WinRmRpcEndpoint } from "@app/lib/gateway-v2/winrm-rpc";import { executeWinRMGatewayOperation, TWinRMConnection, TWinRMCredentials } from "@app/services/app-connection/winrm";import { TCertificateSyncDALFactory } from "@app/services/certificate-sync/certificate-sync-dal";import { TSyncMetadata } from "@app/services/certificate-sync/certificate-sync-schemas";-import { exportCertificateForSync, PkiSyncExportFormat } from "../pki-sync-export-fns";+import { exportCertificateForSync, PemCertificateExtension, PkiSyncExportFormat } from "../pki-sync-export-fns";import { TCertificateMap, TPkiSyncSyncResult, TPkiSyncWithCredentials } from "../pki-sync-types";import { TWindowsServerPkiSyncConfig } from "./windows-server-pki-sync-types";@@ -23,8 +24,11 @@ type TWindowsServerPkiSyncFactoryDeps = {type TWindowsServerSyncOptions = {certificateNameSchema?: string;exportFormat?: PkiSyncExportFormat;+ pemCertificateExtension?: PemCertificateExtension;+ combineCertificateChain?: boolean;includePrivateKey?: boolean;canRemoveCertificates?: boolean;+ fileAccessRules?: Array<{ identity: string; access: string }>;};const TRAILING_BACKSLASH = new RE2("\\\\+$");@@ -87,7 +91,7 @@ const reconcileWindowsServerRemovals = async (args: {try {if (orphanPaths.length > 0) {await executeWinRMGatewayOperation(- { ...target, endpoint: "/v1/remove", params: { paths: orphanPaths } },+ { ...target, endpoint: WinRmRpcEndpoint.RemoveFiles, params: { paths: orphanPaths } },gatewayDeps);}@@ -165,7 +169,9 @@ export const windowsServerPkiSyncFactory = ({privateKey,includePrivateKey,password: exportPassword,- alias: baseName+ alias: baseName,+ pemCertificateExtension: options.pemCertificateExtension,+ combineCertificateChain: options.combineCertificateChain});const paths: string[] = [];@@ -177,7 +183,14 @@ export const windowsServerPkiSyncFactory = ({deliveredPaths.add(fullPath);}- await executeWinRMGatewayOperation({ ...target, endpoint: "/v1/deliver", params: { files } }, gatewayDeps);+ await executeWinRMGatewayOperation(+ {+ ...target,+ endpoint: WinRmRpcEndpoint.DeliverFiles,+ params: { files, accessRules: options.fileAccessRules ?? [] }+ },+ gatewayDeps+ );if (typeof certificateId === "string") {let record = await certificateSyncDAL.findByPkiSyncAndCertificate(pkiSync.id, certificateId);@@ -258,7 +271,7 @@ export const windowsServerPkiSyncFactory = ({if (pathsToRemove.size > 0) {const target = buildWinRMTarget(pkiSync);await executeWinRMGatewayOperation(- { ...target, endpoint: "/v1/remove", params: { paths: Array.from(pathsToRemove) } },+ { ...target, endpoint: WinRmRpcEndpoint.RemoveFiles, params: { paths: Array.from(pathsToRemove) } },gatewayDeps);}diff --git a/backend/src/services/pki-sync/windows-server/windows-server-pki-sync-schemas.ts b/backend/src/services/pki-sync/windows-server/windows-server-pki-sync-schemas.tsindex 51246fcf28..4afc2e23c0 100644--- a/backend/src/services/pki-sync/windows-server/windows-server-pki-sync-schemas.ts+++ b/backend/src/services/pki-sync/windows-server/windows-server-pki-sync-schemas.ts@@ -1,11 +1,10 @@import RE2 from "re2";import { z } from "zod";-import { openApiHidden } from "@app/server/lib/schemas";import { AppConnection } from "@app/services/app-connection/app-connection-enums";import { buildCertificateNameSchemaTestName } from "@app/services/pki-sync/pki-sync-certificate-name-fns";import { PkiSync } from "@app/services/pki-sync/pki-sync-enums";-import { PkiSyncExportFormat } from "@app/services/pki-sync/pki-sync-export-fns";+import { PemCertificateExtension, PkiSyncExportFormat } from "@app/services/pki-sync/pki-sync-export-fns";import { PkiSyncSchema } from "@app/services/pki-sync/pki-sync-schemas";import { WINDOWS_SERVER_NAMING } from "./windows-server-pki-sync-constants";@@ -24,6 +23,16 @@ const WINDOWS_PATH_ALLOWED_CHARS = new RE2("^[A-Za-z0-9 ._\\-\\\\/:]+$");// Runs of 2+ separators (e.g. C:\\certs). Windows can normalize these to a different location, so a// delivery would silently land elsewhere.const WINDOWS_DOUBLE_SEPARATOR = new RE2("[\\\\/]{2,}");+// A Windows account name (user or group), e.g. "DOMAIN\\svc", "[email protected]", "BUILTIN\\Administrators",+// "NT AUTHORITY\\SYSTEM", ".\\localuser". Restricted so it is safe to embed in the icacls command on the host.+const WINDOWS_IDENTITY = new RE2("^[A-Za-z0-9 ._@$\\\\-]+$");++// Access level granted on delivered files; mapped to icacls rights on the gateway (R / M / F).+export enum WindowsFileAccess {+ Read = "read",+ Modify = "modify",+ FullControl = "full-control"+}export const WindowsServerPkiSyncConfigSchema = z.object({destinationPath: z@@ -48,6 +57,24 @@ export const WindowsServerPkiSyncOptionsSchema = z.object({includeRootCa: z.boolean().default(false),includePrivateKey: z.boolean().default(true),exportFormat: z.nativeEnum(PkiSyncExportFormat).default(PkiSyncExportFormat.Pkcs12),+ pemCertificateExtension: z.nativeEnum(PemCertificateExtension).default(PemCertificateExtension.Pem),+ combineCertificateChain: z.boolean().default(false),+ fileAccessRules: z+ .array(+ z.object({+ identity: z+ .string()+ .trim()+ .min(1)+ .max(256)+ .refine((v) => WINDOWS_IDENTITY.test(v), {+ message: "Identity must be a valid Windows user or group (for example DOMAIN\\svc-account)"+ }),+ access: z.nativeEnum(WindowsFileAccess)+ })+ )+ .max(20)+ .optional(),certificateNameSchema: z.string().trim()@@ -89,7 +116,6 @@ export const CreateWindowsServerPkiSyncSchema = zcredentials: WindowsServerPkiSyncCredentialsSchema.optional(),subscriberId: z.string().nullish(),connectionId: z.string(),- projectId: z.string().trim().min(1).optional().describe(openApiHidden()),applicationId: z.string().uuid().optional(),certificateIds: z.array(z.string().uuid()).optional()})diff --git a/docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdx b/docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdxindex eb9fc087f8..efa3feff92 100644--- a/docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdx+++ b/docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdx@@ -30,6 +30,10 @@ Deploy certificates from Infisical to a directory on a Linux server over SSH. Fi4. Configure the **Sync Options**:- **Export Format**: Choose **PEM** to write separate certificate, chain, and key files, or **PKCS#12** to write a single password-protected `.pfx` bundle.+ - **Certificate File Extension**: For PEM, choose `.pem` (default) or `.crt` for the certificate and chain files. Both hold the same PEM-encoded content, so pick the one the consuming service expects.+ - **Combine Certificate and Chain**: For PEM, write the leaf certificate followed by the chain in a single file (a full-chain file, as nginx expects) and skip the separate chain file.+ - **File Permissions** and **Private Key Permissions**: Octal modes for the delivered certificate and chain files (default `644`) and for the private key file (default `600`).+ - **Owner** and **Group**: Optionally set the owner and group on the delivered files. Changing ownership requires the connection user to be root or to have passwordless sudo.- **PKCS#12 Password**: Required when the export format is PKCS#12. It protects the delivered bundle.- **Include Private Key**: For PEM, controls whether the private key is written alongside the certificate. The sync fails for a certificate whose key is not available, for example one issued from an external CSR.- **Include Root CA in Certificate Chain**: Include the root CA in the delivered chain. Leave it off when the consuming service only needs the intermediates.@@ -77,19 +81,27 @@ Deploy certificates from Infisical to a directory on a Linux server over SSH. Fi## Export Formats-<Note>- The file extension is decided by the export format, not by the name schema. The name schema only provides the base name.- - **PEM**: `<name>.pem` (certificate), `<name>.chain.pem` (chain), and `<name>.key` (private key, when included).- - **PKCS#12**: `<name>.pfx`, a single password-protected bundle containing the certificate, chain, and key.-</Note>+The file extension is set by the export format, not by the name schema. The name schema only provides the base file name.-## How It Works+**PEM** writes the certificate, chain, and private key (when included) as separate files. The certificate and chain files use the extension you select, either `.pem` (default) or `.crt`.++**PKCS#12** writes a single password-protected `.pfx` bundle that contains the certificate, chain, and private key.++For a certificate whose common name is `app.example.com`, synced to `/etc/ssl/certs` with the default `{{commonName}}` name schema, the delivered files are:-When syncing certificates, Infisical opens an SSH session to the server and, for each certificate:+```text+PEM (.pem extension)+ /etc/ssl/certs/app.example.com.pem certificate+ /etc/ssl/certs/app.example.com.chain.pem chain+ /etc/ssl/certs/app.example.com.key private key (when included)++PKCS#12+ /etc/ssl/certs/app.example.com.pfx+```++## How It Works-1. Packages the certificate in the chosen export format.-2. Writes each file to a temporary name in the destination directory.-3. Renames the temporary file over the final name so the delivered file is always complete.+When syncing certificates, Infisical opens an SSH session to the server and, for each certificate, packages it in the chosen export format and writes the resulting files to the destination directory. Files are written atomically over SFTP so a reader never sees a partially written certificate or key.## Removing Certificatesdiff --git a/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx b/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdxindex 83387b33a5..c04f08b5ce 100644--- a/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx+++ b/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx@@ -34,6 +34,9 @@ Deploy certificates from Infisical to a directory on a Windows server over WinRM4. Configure the **Sync Options**:- **Export Format**: Choose **PKCS#12** to write a single password-protected `.pfx` bundle, or **PEM** to write separate certificate, chain, and key files.+ - **Certificate File Extension**: For PEM, choose `.pem` (default) or `.crt` for the certificate and chain files. Both hold the same PEM-encoded content, so pick the one the consuming service expects.+ - **Combine Certificate and Chain**: For PEM, write the leaf certificate followed by the chain in a single file (a full-chain file) and skip the separate chain file.+ - **File Permissions**: Optionally grant Windows users or groups (for example a service account) Read, Modify, or Full Control on the delivered files, so you can restrict who reads the private key. Rules are added on top of the destination folder's inherited permissions.- **PKCS#12 Password**: Required when the export format is PKCS#12. It protects the delivered bundle.- **Include Private Key**: For PEM, controls whether the private key is written alongside the certificate. The sync fails for a certificate whose key is not available, for example one issued from an external CSR.- **Include Root CA in Certificate Chain**: Include the root CA in the delivered chain. Leave it off when the consuming service only needs the intermediates.@@ -83,19 +86,27 @@ Deploy certificates from Infisical to a directory on a Windows server over WinRM## Export Formats-<Note>- The file extension is decided by the export format, not by the name schema. The name schema only provides the base name.- - **PKCS#12**: `<name>.pfx`, a single password-protected bundle containing the certificate, chain, and key.- - **PEM**: `<name>.pem` (certificate), `<name>.chain.pem` (chain), and `<name>.key` (private key, when included).-</Note>+The file extension is set by the export format, not by the name schema. The name schema only provides the base file name.-## How It Works+**PKCS#12** writes a single password-protected `.pfx` bundle that contains the certificate, chain, and private key.++**PEM** writes the certificate, chain, and private key (when included) as separate files. The certificate and chain files use the extension you select, either `.pem` (default) or `.crt`.++For a certificate whose common name is `app.example.com`, synced to `C:\certs` with the default `{{commonName}}` name schema, the delivered files are:-When syncing certificates, Infisical asks the Gateway to open a WinRM session to the server and, for each certificate:+```text+PKCS#12+ C:\certs\app.example.com.pfx-1. Packages the certificate in the chosen export format.-2. Writes each file to a temporary name in the destination directory.-3. Renames the temporary file over the final name so the delivered file is always complete.+PEM (.pem extension)+ C:\certs\app.example.com.pem certificate+ C:\certs\app.example.com.chain.pem chain+ C:\certs\app.example.com.key private key (when included)+```++## How It Works++When syncing certificates, Infisical asks the Gateway to open a WinRM session to the server and, for each certificate, packages it in the chosen export format and writes the resulting files to the destination directory. Files are written atomically so a reader never sees a partially written certificate or key.## Removing Certificates@@ -116,10 +127,6 @@ These are IIS requirements, configured once on the Windows host (the CCS feature## FAQ-<Accordion title="Which transport does the sync use?">- By default (SSL disabled) the connection uses HTTP with NTLM message encryption on port 5985, which needs no server certificate. Enable SSL on the connection to use HTTPS on port 5986. For a self-signed HTTPS listener, paste its certificate as the SSL certificate so it can be authenticated.-</Accordion>-<Accordion title="Can I import certificates from a Windows server back into Infisical?">No. The Windows Server sync only delivers certificates to the server. It does not read certificates back into Infisical.</Accordion>diff --git a/docs/integrations/app-connections/winrm.mdx b/docs/integrations/app-connections/winrm.mdxindex f8889c9d46..603d1e0b70 100644--- a/docs/integrations/app-connections/winrm.mdx+++ b/docs/integrations/app-connections/winrm.mdx@@ -76,12 +76,12 @@ Infisical supports connecting to Windows hosts over WinRM to deliver certificate## Transport-<Note>- By default (SSL disabled) the connection uses HTTP with NTLM message encryption on port 5985, which keeps the certificate and key confidential without a server certificate. This is the zero-configuration posture most Windows hosts already ship with. Enable SSL to use HTTPS on port 5986. For a self-signed HTTPS listener, paste its certificate as the SSL certificate so it can be authenticated.-</Note>+By default (SSL disabled) the connection uses HTTP with NTLM message encryption on port 5985, which keeps the certificate and key confidential without a server certificate. This is the zero-configuration posture most Windows hosts already ship with.++Enable SSL to use HTTPS on port 5986. For a self-signed HTTPS listener, paste its certificate as the SSL certificate so it can be authenticated. For a host on an untrusted network, prefer HTTPS.## FAQ<Accordion title="Why does this connection require a Gateway?">- The Windows host is inside your network and is not reachable from Infisical directly. The Gateway sits inside your network, reaches the host, and runs the WinRM session on Infisical's behalf.+ The Gateway runs the WinRM session on Infisical's behalf, so a Gateway with access to the Windows host is always required.</Accordion>diff --git a/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx b/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsxindex f5ec635ec2..d6f7eb9770 100644--- a/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx+++ b/frontend/src/components/pki-syncs/forms/CreatePkiSyncForm.tsx@@ -167,9 +167,34 @@ export const CreatePkiSyncForm = ({setSelectedTabIndex((prev) => prev - 1);};- const { handleSubmit, trigger, control } = formMethods;+ const { handleSubmit, trigger, control, getValues, setError } = formMethods;- const isStepValid = async (index: number) => trigger(FORM_TABS[index].fields);+ const isStepValid = async (index: number) => {+ const isValid = await trigger(FORM_TABS[index].fields);+ if (!isValid) return false;++ if (FORM_TABS[index].key === "options") {+ const values = getValues() as {+ destination?: PkiSync;+ syncOptions?: { exportFormat?: PkiSyncExportFormat };+ credentials?: { exportPassword?: string };+ };+ const requiresPassword =+ (values.destination === PkiSync.WindowsServer ||+ values.destination === PkiSync.LinuxServer) &&+ values.syncOptions?.exportFormat === PkiSyncExportFormat.Pkcs12 &&+ !values.credentials?.exportPassword;+ if (requiresPassword) {+ setError("credentials.exportPassword" as FieldPath<TPkiSyncForm>, {+ type: "manual",+ message: "A password is required for PKCS#12 exports"+ });+ return false;+ }+ }++ return true;+ };const isFinalStep = selectedTabIndex === FORM_TABS.length - 1;diff --git a/frontend/src/components/pki-syncs/forms/EditPkiSyncForm.tsx b/frontend/src/components/pki-syncs/forms/EditPkiSyncForm.tsxindex 380ba039e5..522e4df56f 100644--- a/frontend/src/components/pki-syncs/forms/EditPkiSyncForm.tsx+++ b/frontend/src/components/pki-syncs/forms/EditPkiSyncForm.tsx@@ -65,7 +65,7 @@ export const EditPkiSyncForm = ({ pkiSync, fields, onComplete }: Props) => {Component = <PkiSyncDestinationFields />;break;case PkiSyncEditFields.Options:- Component = <PkiSyncOptionsFields destination={pkiSync.destination} />;+ Component = <PkiSyncOptionsFields destination={pkiSync.destination} isUpdate />;break;case PkiSyncEditFields.Mappings:Component = <PkiSyncFieldMappingsFields destination={pkiSync.destination} />;diff --git a/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsx b/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsxindex ee10cdaa56..02bfd3f187 100644--- a/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsx+++ b/frontend/src/components/pki-syncs/forms/PkiSyncOptionsFields/PkiSyncOptionsFields.tsx@@ -1,20 +1,41 @@-import { Controller, useFormContext } from "react-hook-form";-import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";+import { Controller, useFieldArray, useFormContext } from "react-hook-form";+import { faPlus, faQuestionCircle, faTrash } from "@fortawesome/free-solid-svg-icons";import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";-import { FormControl, Input, Select, SelectItem, Switch, Tooltip } from "@app/components/v2";-import { PkiSync, PkiSyncExportFormat, usePkiSyncOption } from "@app/hooks/api/pkiSyncs";+import {+ Button,+ FormControl,+ IconButton,+ Input,+ Select,+ SelectItem,+ Switch,+ Tooltip+} from "@app/components/v2";+import {+ PemCertificateExtension,+ PkiSync,+ PkiSyncExportFormat,+ usePkiSyncOption,+ WindowsFileAccess+} from "@app/hooks/api/pkiSyncs";import { TPkiSyncForm } from "../schemas/pki-sync-schema";type Props = {destination?: PkiSync;+ isUpdate?: boolean;};-export const PkiSyncOptionsFields = ({ destination }: Props) => {+export const PkiSyncOptionsFields = ({ destination, isUpdate }: Props) => {const { control, watch } = useFormContext<TPkiSyncForm>();const currentDestination = destination || watch("destination");const { syncOption } = usePkiSyncOption(currentDestination);+ const {+ fields: accessRuleFields,+ append: appendAccessRule,+ remove: removeAccessRule+ } = useFieldArray({ control, name: "syncOptions.fileAccessRules" as never });return (<>@@ -440,6 +461,57 @@ export const PkiSyncOptionsFields = ({ destination }: Props) => {</FormControl>)}/>+ {watch("syncOptions.exportFormat") === PkiSyncExportFormat.Pem && (+ <Controller+ control={control}+ name="syncOptions.pemCertificateExtension"+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ isError={Boolean(error)}+ errorText={error?.message}+ label="Certificate File Extension"+ tooltipText="The extension for the certificate and chain files. Both hold the same PEM-encoded content; choose the one the consuming service expects."+ >+ <Select+ value={value ?? PemCertificateExtension.Pem}+ onValueChange={(v) => onChange(v as PemCertificateExtension)}+ className="w-full border border-mineshaft-500"+ position="popper"+ >+ <SelectItem value={PemCertificateExtension.Pem}>.pem</SelectItem>+ <SelectItem value={PemCertificateExtension.Crt}>.crt</SelectItem>+ </Select>+ </FormControl>+ )}+ />+ )}+ {watch("syncOptions.exportFormat") === PkiSyncExportFormat.Pem && (+ <Controller+ control={control}+ name="syncOptions.combineCertificateChain"+ 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="combine-certificate-chain"+ thumbClassName="bg-mineshaft-800"+ onCheckedChange={onChange}+ isChecked={value ?? false}+ >+ <p>+ Combine Certificate and Chain{" "}+ <Tooltip+ className="max-w-md"+ content="When on, the certificate file holds the leaf certificate followed by the chain (a full-chain file, as nginx expects) and no separate chain file is written."+ >+ <FontAwesomeIcon icon={faQuestionCircle} size="sm" className="ml-1" />+ </Tooltip>+ </p>+ </Switch>+ </FormControl>+ )}+ />+ )}{watch("syncOptions.exportFormat") === PkiSyncExportFormat.Pkcs12 && (<Controllercontrol={control}@@ -449,7 +521,11 @@ export const PkiSyncOptionsFields = ({ destination }: Props) => {isError={Boolean(error)}errorText={error?.message}label="PKCS#12 Password"- tooltipText="Protects the .pfx bundle. When editing, leave blank to keep the current password."+ tooltipText={+ isUpdate+ ? "Protects the .pfx bundle. Leave blank to keep the current password."+ : "Protects the .pfx bundle."+ }><Inputtype="password"@@ -491,6 +567,148 @@ export const PkiSyncOptionsFields = ({ destination }: Props) => {</>)}+ {currentDestination === PkiSync.LinuxServer && (+ <>+ <div className="grid grid-cols-2 gap-2">+ <Controller+ control={control}+ name="syncOptions.fileMode"+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ isError={Boolean(error)}+ errorText={error?.message}+ label="File Permissions"+ isOptional+ tooltipText="Octal mode for the delivered certificate and chain files (default 644)."+ >+ <Input value={value ?? ""} onChange={onChange} placeholder="644" />+ </FormControl>+ )}+ />+ <Controller+ control={control}+ name="syncOptions.privateKeyFileMode"+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ isError={Boolean(error)}+ errorText={error?.message}+ label="Private Key Permissions"+ isOptional+ tooltipText="Octal mode for the delivered private key file (default 600)."+ >+ <Input value={value ?? ""} onChange={onChange} placeholder="600" />+ </FormControl>+ )}+ />+ </div>+ <div className="grid grid-cols-2 gap-2">+ <Controller+ control={control}+ name="syncOptions.owner"+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ isError={Boolean(error)}+ errorText={error?.message}+ label="Owner"+ isOptional+ tooltipText="Owner applied to the delivered files (chown). Requires the connection user to be root or have passwordless sudo."+ >+ <Input value={value ?? ""} onChange={onChange} placeholder="e.g. root" />+ </FormControl>+ )}+ />+ <Controller+ control={control}+ name="syncOptions.group"+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ isError={Boolean(error)}+ errorText={error?.message}+ label="Group"+ isOptional+ tooltipText="Group applied to the delivered files (chown). Requires the connection user to be root or have passwordless sudo."+ >+ <Input value={value ?? ""} onChange={onChange} placeholder="e.g. ssl-cert" />+ </FormControl>+ )}+ />+ </div>+ </>+ )}++ {currentDestination === PkiSync.WindowsServer && (+ <FormControl+ label="File Permissions"+ isOptional+ tooltipText="Grant Windows users or groups access to the delivered files (for example, restrict who can read the private key). Rules are added on top of the destination folder's inherited permissions."+ >+ <div className="flex flex-col gap-2">+ {accessRuleFields.map((ruleField, index) => (+ <div key={ruleField.id} className="flex items-start gap-2">+ <Controller+ control={control}+ name={`syncOptions.fileAccessRules.${index}.identity` as never}+ render={({ field, fieldState: { error } }) => (+ <FormControl+ isError={Boolean(error)}+ errorText={error?.message}+ className="mb-0 flex-1"+ >+ <Input+ {...field}+ value={(field.value as string) ?? ""}+ placeholder="DOMAIN\svc-account"+ />+ </FormControl>+ )}+ />+ <Controller+ control={control}+ name={`syncOptions.fileAccessRules.${index}.access` as never}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <FormControl+ isError={Boolean(error)}+ errorText={error?.message}+ className="mb-0 w-40"+ >+ <Select+ value={(value as WindowsFileAccess) ?? WindowsFileAccess.Read}+ onValueChange={onChange}+ className="w-full border border-mineshaft-500"+ position="popper"+ >+ <SelectItem value={WindowsFileAccess.Read}>Read</SelectItem>+ <SelectItem value={WindowsFileAccess.Modify}>Modify</SelectItem>+ <SelectItem value={WindowsFileAccess.FullControl}>Full Control</SelectItem>+ </Select>+ </FormControl>+ )}+ />+ <IconButton+ ariaLabel="Remove permission rule"+ variant="plain"+ className="mt-1"+ onClick={() => removeAccessRule(index)}+ >+ <FontAwesomeIcon icon={faTrash} />+ </IconButton>+ </div>+ ))}+ <div>+ <Button+ type="button"+ variant="outline_bg"+ size="xs"+ leftIcon={<FontAwesomeIcon icon={faPlus} />}+ onClick={() => appendAccessRule({ identity: "", access: WindowsFileAccess.Read })}+ >+ Add Permission+ </Button>+ </div>+ </div>+ </FormControl>+ )}+<Controllercontrol={control}name="syncOptions.certificateNameSchema"diff --git a/frontend/src/components/pki-syncs/forms/schemas/linux-server-pki-sync-destination-schema.ts b/frontend/src/components/pki-syncs/forms/schemas/linux-server-pki-sync-destination-schema.tsindex 0f99511f1c..57b843aea0 100644--- a/frontend/src/components/pki-syncs/forms/schemas/linux-server-pki-sync-destination-schema.ts+++ b/frontend/src/components/pki-syncs/forms/schemas/linux-server-pki-sync-destination-schema.ts@@ -1,6 +1,6 @@import { z } from "zod";-import { PkiSync, PkiSyncExportFormat } from "@app/hooks/api/pkiSyncs";+import { PemCertificateExtension, PkiSync, PkiSyncExportFormat } from "@app/hooks/api/pkiSyncs";import { BasePkiSyncSchema } from "./base-pki-sync-schema";@@ -15,7 +15,41 @@ const compileNameSchema = (val: string) =>const LinuxServerSyncOptionsSchema = z.object({exportFormat: z.nativeEnum(PkiSyncExportFormat).default(PkiSyncExportFormat.Pem),+ pemCertificateExtension: z+ .nativeEnum(PemCertificateExtension)+ .default(PemCertificateExtension.Pem),+ combineCertificateChain: z.boolean().default(false),includePrivateKey: z.boolean().default(true),+ fileMode: z+ .string()+ .trim()+ .refine((m) => !m || /^0?[0-7]{3}$/.test(m), {+ message: "File mode must be a 3-digit octal value (e.g. 644)"+ })+ .optional(),+ privateKeyFileMode: z+ .string()+ .trim()+ .refine((m) => !m || /^0?[0-7]{3}$/.test(m), {+ message: "Private key file mode must be a 3-digit octal value (e.g. 600)"+ })+ .optional(),+ owner: z+ .string()+ .trim()+ .max(32)+ .refine((v) => !v || /^[a-z_][a-z0-9_-]*\$?$/i.test(v), {+ message: "Owner must be a valid Linux user name"+ })+ .optional(),+ group: z+ .string()+ .trim()+ .max(32)+ .refine((v) => !v || /^[a-z_][a-z0-9_-]*\$?$/i.test(v), {+ message: "Group must be a valid Linux group name"+ })+ .optional(),certificateNameSchema: z.string().trim()diff --git a/frontend/src/components/pki-syncs/forms/schemas/windows-server-pki-sync-destination-schema.ts b/frontend/src/components/pki-syncs/forms/schemas/windows-server-pki-sync-destination-schema.tsindex 2d9b40db75..eee88f4ff8 100644--- a/frontend/src/components/pki-syncs/forms/schemas/windows-server-pki-sync-destination-schema.ts+++ b/frontend/src/components/pki-syncs/forms/schemas/windows-server-pki-sync-destination-schema.ts@@ -1,6 +1,11 @@import { z } from "zod";-import { PkiSync, PkiSyncExportFormat } from "@app/hooks/api/pkiSyncs";+import {+ PemCertificateExtension,+ PkiSync,+ PkiSyncExportFormat,+ WindowsFileAccess+} from "@app/hooks/api/pkiSyncs";import { BasePkiSyncSchema } from "./base-pki-sync-schema";@@ -15,6 +20,26 @@ const compileNameSchema = (val: string) =>const WindowsServerSyncOptionsSchema = z.object({exportFormat: z.nativeEnum(PkiSyncExportFormat).default(PkiSyncExportFormat.Pkcs12),+ pemCertificateExtension: z+ .nativeEnum(PemCertificateExtension)+ .default(PemCertificateExtension.Pem),+ combineCertificateChain: z.boolean().default(false),+ fileAccessRules: z+ .array(+ z.object({+ identity: z+ .string()+ .trim()+ .min(1, "Identity is required")+ .max(256)+ .refine((v) => /^[A-Za-z0-9 ._@$\\-]+$/.test(v), {+ message: "Identity must be a valid Windows user or group (e.g. DOMAIN\\svc-account)"+ }),+ access: z.nativeEnum(WindowsFileAccess)+ })+ )+ .max(20)+ .optional(),includePrivateKey: z.boolean().default(true),certificateNameSchema: z.string()diff --git a/frontend/src/hooks/api/pkiSyncs/enums.ts b/frontend/src/hooks/api/pkiSyncs/enums.tsindex 16db6bdb86..ff8203bb9c 100644--- a/frontend/src/hooks/api/pkiSyncs/enums.ts+++ b/frontend/src/hooks/api/pkiSyncs/enums.ts@@ -16,6 +16,17 @@ export enum PkiSyncExportFormat {Pkcs12 = "pkcs12"}+export enum PemCertificateExtension {+ Pem = "pem",+ Crt = "crt"+}++export enum WindowsFileAccess {+ Read = "read",+ Modify = "modify",+ FullControl = "full-control"+}+export enum PkiSyncStatus {Pending = "pending",Running = "running",diff --git a/frontend/src/hooks/api/pkiSyncs/types/linux-server-sync.ts b/frontend/src/hooks/api/pkiSyncs/types/linux-server-sync.tsindex 73a85ed476..1f7df07c91 100644--- a/frontend/src/hooks/api/pkiSyncs/types/linux-server-sync.ts+++ b/frontend/src/hooks/api/pkiSyncs/types/linux-server-sync.ts@@ -1,6 +1,6 @@import { AppConnection } from "@app/hooks/api/appConnections/enums";-import { PkiSync, PkiSyncExportFormat } from "../enums";+import { PemCertificateExtension, PkiSync, PkiSyncExportFormat } from "../enums";import { TRootPkiSync } from "./common";export type TLinuxServerPkiSync = TRootPkiSync & {@@ -10,7 +10,13 @@ export type TLinuxServerPkiSync = TRootPkiSync & {};syncOptions: TRootPkiSync["syncOptions"] & {exportFormat?: PkiSyncExportFormat;+ pemCertificateExtension?: PemCertificateExtension;+ combineCertificateChain?: boolean;includePrivateKey?: boolean;+ fileMode?: string;+ privateKeyFileMode?: string;+ owner?: string;+ group?: string;};connection: {app: AppConnection.SSH;diff --git a/frontend/src/hooks/api/pkiSyncs/types/windows-server-sync.ts b/frontend/src/hooks/api/pkiSyncs/types/windows-server-sync.tsindex d3e5708b6d..a9408119a7 100644--- a/frontend/src/hooks/api/pkiSyncs/types/windows-server-sync.ts+++ b/frontend/src/hooks/api/pkiSyncs/types/windows-server-sync.ts@@ -1,6 +1,6 @@import { AppConnection } from "@app/hooks/api/appConnections/enums";-import { PkiSync, PkiSyncExportFormat } from "../enums";+import { PemCertificateExtension, PkiSync, PkiSyncExportFormat, WindowsFileAccess } from "../enums";import { TRootPkiSync } from "./common";export type TWindowsServerPkiSync = TRootPkiSync & {@@ -10,7 +10,10 @@ export type TWindowsServerPkiSync = TRootPkiSync & {};syncOptions: TRootPkiSync["syncOptions"] & {exportFormat?: PkiSyncExportFormat;+ pemCertificateExtension?: PemCertificateExtension;+ combineCertificateChain?: boolean;includePrivateKey?: boolean;+ fileAccessRules?: { identity: string; access: WindowsFileAccess }[];};connection: {app: AppConnection.WinRM;diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/WinRMConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/WinRMConnectionForm.tsxindex 345ae84534..da5adf6db3 100644--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/WinRMConnectionForm.tsx+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/WinRMConnectionForm.tsx@@ -253,7 +253,7 @@ export const WinRMConnectionForm = ({ appConnection, onSubmit }: Props) => {name="credentials.sslEnabled"control={control}render={({ field: { value, onChange }, fieldState: { error } }) => (- <Field className="mb-4">+ <Field className="mt-2 mb-4"><Field orientation="horizontal"><FieldContent><Label htmlFor="ssl-enabled">Enable SSL</Label>