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
HTTPS enforcement
Carlos Monastyrskia18ee7d9b2db
diff --git a/backend/src/lib/gateway-v2/winrm-rpc.ts b/backend/src/lib/gateway-v2/winrm-rpc.tsindex af6d6f3693..c209a24941 100644--- a/backend/src/lib/gateway-v2/winrm-rpc.ts+++ b/backend/src/lib/gateway-v2/winrm-rpc.ts@@ -5,8 +5,8 @@ import { logger } from "@app/lib/logger";export type WinRmRpcEndpoint = "/v1/test" | "/v1/deliver" | "/v1/remove";export type WinRmTransportParams = {- useHttps?: boolean;insecure?: boolean;+ caCertificate?: string;};export type WinRmDeliverFile = {diff --git a/backend/src/services/app-connection/winrm/winrm-connection-fns.ts b/backend/src/services/app-connection/winrm/winrm-connection-fns.tsindex ed8f7fdaa6..340245d727 100644--- a/backend/src/services/app-connection/winrm/winrm-connection-fns.ts+++ b/backend/src/services/app-connection/winrm/winrm-connection-fns.ts@@ -21,8 +21,8 @@ export type TWinRMCredentials = {port: number;username: string;password: string;- useHttps?: boolean;insecure?: boolean;+ caCertificate?: string;};export const getWinRMConnectionListItem = () => ({@@ -88,8 +88,8 @@ export const executeWinRMGatewayOperation = async <T>(username: args.credentials.username,password: args.credentials.password,params: {- useHttps: args.credentials.useHttps ?? false,- insecure: args.credentials.insecure ?? false,+ insecure: args.credentials.caCertificate ? false : (args.credentials.insecure ?? false),+ ...(args.credentials.caCertificate ? { caCertificate: args.credentials.caCertificate } : {}),...args.params}}diff --git a/backend/src/services/app-connection/winrm/winrm-connection-schemas.ts b/backend/src/services/app-connection/winrm/winrm-connection-schemas.tsindex 00c9563ec3..7891088ba4 100644--- a/backend/src/services/app-connection/winrm/winrm-connection-schemas.ts+++ b/backend/src/services/app-connection/winrm/winrm-connection-schemas.ts@@ -17,13 +17,7 @@ export const WinRMUsernamePasswordCredentialsSchema = z.object({.min(1, "Host required").max(255).describe("The Windows host's DNS name (FQDN) or IP address."),- port: z.coerce- .number()- .int()- .min(1)- .max(65535)- .default(5985)- .describe("The WinRM port. 5985 for NTLM-encrypted HTTP, 5986 for HTTPS."),+ port: z.coerce.number().int().min(1).max(65535).default(5986).describe("The WinRM HTTPS port (typically 5986)."),username: z.string().trim()@@ -31,11 +25,20 @@ export const WinRMUsernamePasswordCredentialsSchema = z.object({.max(255).describe("Windows login: DOMAIN\\user or user@domain."),password: z.string().min(1, "Password required").max(255).describe("The account password."),- useHttps: z.boolean().default(false).describe("Use HTTPS (port 5986) instead of NTLM-encrypted HTTP (port 5985)."),+ caCertificate: z+ .string()+ .trim()+ .max(8192)+ .optional()+ .describe(+ "PEM CA certificate used to verify a self-signed WinRM HTTPS listener. When set, TLS verification is enforced against it and 'insecure' is ignored."+ ),insecure: z.boolean().default(false)- .describe("Skip TLS certificate verification when HTTPS is used (for self-signed WinRM listeners).")+ .describe(+ "Skip TLS certificate verification. Gives confidentiality but not server authentication; prefer pinning a CA certificate for self-signed listeners."+ )});const BaseWinRMConnectionSchema = BaseAppConnectionSchema.extend({ app: z.literal(AppConnection.WinRM) });@@ -53,7 +56,7 @@ export const SanitizedWinRMConnectionSchema = z.discriminatedUnion("method", [host: true,port: true,username: true,- useHttps: true,+ caCertificate: true,insecure: true})}).describe(JSON.stringify({ title: `${APP_CONNECTION_NAME_MAP[AppConnection.WinRM]} (Username and Password)` }))diff --git a/backend/src/services/pki-sync/pki-sync-queue.ts b/backend/src/services/pki-sync/pki-sync-queue.tsindex 494240ff8a..ea74667dc9 100644--- a/backend/src/services/pki-sync/pki-sync-queue.ts+++ b/backend/src/services/pki-sync/pki-sync-queue.ts@@ -801,7 +801,6 @@ export const pkiSyncQueueFactory = ({});-isSuccess = true;} catch (err) {logger.error(diff --git a/backend/src/services/pki-sync/pki-sync-service.ts b/backend/src/services/pki-sync/pki-sync-service.tsindex 5ac5cb984f..3f9726f41d 100644--- a/backend/src/services/pki-sync/pki-sync-service.ts+++ b/backend/src/services/pki-sync/pki-sync-service.ts@@ -22,9 +22,9 @@ import { CertificateSyncStatus } from "../certificate-sync/certificate-sync-enumimport { TSyncMetadata } from "../certificate-sync/certificate-sync-schemas";import { certificateNameSchemaAllowsMultipleCertificates } from "./pki-sync-certificate-name-fns";import { encryptPkiSyncCredentials } from "./pki-sync-credentials-fns";-import { PkiSyncExportFormat } from "./pki-sync-export-fns";import { TPkiSyncDALFactory } from "./pki-sync-dal";import { PkiSync, PkiSyncStatus } from "./pki-sync-enums";+import { PkiSyncExportFormat } from "./pki-sync-export-fns";import { enterprisePkiSyncCheck, getPkiSyncProviderCapabilities, listPkiSyncOptions } from "./pki-sync-fns";import { PKI_SYNC_CONNECTION_MAP, PKI_SYNC_NAME_MAP } from "./pki-sync-maps";import { TPkiSyncQueueFactory } from "./pki-sync-queue";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 30305fcab1..4f82e18636 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@@ -35,11 +35,11 @@ const buildWinRMTarget = (pkiSync: TPkiSyncWithCredentials) => {const winrmCredentials: TWinRMCredentials = {host: credentials.host,- port: credentials.port ?? 5985,+ port: credentials.port ?? 5986,username: credentials.username,password: credentials.password,- useHttps: credentials.useHttps,- insecure: credentials.insecure+ insecure: credentials.insecure,+ caCertificate: credentials.caCertificate};return {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 358665e6cc..51246fcf28 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@@ -10,8 +10,10 @@ import { PkiSyncSchema } from "@app/services/pki-sync/pki-sync-schemas";import { WINDOWS_SERVER_NAMING } from "./windows-server-pki-sync-constants";-// Accepts a drive-letter path (C:\...) or a UNC path (\\server\share\...).-const WINDOWS_ABSOLUTE_PATH = new RE2("^([a-zA-Z]:\\\\|\\\\\\\\)");+// Accepts only a local drive-letter path (C:\...). UNC paths (\\server\share) are rejected: a+// UNC destination would make the target host authenticate to, and write private key material to, an+// arbitrary SMB server, so remote shares must go through a separately authorized connection instead.+const WINDOWS_ABSOLUTE_PATH = new RE2("^[a-zA-Z]:\\\\");// Rejects a ".." path segment. Windows treats both "\" and "/" as separators, so both must be// checked or "C:\certs/../.." would slip past a backslash-only test.const WINDOWS_PATH_TRAVERSAL = new RE2("(^|[\\\\/])\\.\\.([\\\\/]|$)");@@ -20,7 +22,7 @@ const WINDOWS_PATH_TRAVERSAL = new RE2("(^|[\\\\/])\\.\\.([\\\\/]|$)");// code points PowerShell also treats as string delimiters, so it cannot break out of the literal.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; a single leading UNC prefix (\\server) is stripped first.+// delivery would silently land elsewhere.const WINDOWS_DOUBLE_SEPARATOR = new RE2("[\\\\/]{2,}");export const WindowsServerPkiSyncConfigSchema = z.object({@@ -30,13 +32,13 @@ export const WindowsServerPkiSyncConfigSchema = z.object({.min(1, "Destination path is required").max(4096, "Destination path is too long").refine((p) => WINDOWS_ABSOLUTE_PATH.test(p), {- message: "Destination path must be an absolute Windows path (for example C:\\certs or \\\\server\\share)"+ message: "Destination path must be an absolute Windows drive path (for example C:\\certs)"}).refine((p) => WINDOWS_PATH_ALLOWED_CHARS.test(p), {message: "Destination path may only contain letters, digits, spaces, and the characters . _ - \\ / :"}).refine((p) => !WINDOWS_PATH_TRAVERSAL.test(p), { message: "Destination path must not contain '..'" })- .refine((p) => !WINDOWS_DOUBLE_SEPARATOR.test(p.startsWith("\\\\") ? p.slice(2) : p), {+ .refine((p) => !WINDOWS_DOUBLE_SEPARATOR.test(p), {message: "Destination path must not contain consecutive path separators"})});diff --git a/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx b/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdxindex c5a337b3e2..973c06f8a2 100644--- a/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx+++ b/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx@@ -17,7 +17,7 @@ Deploy certificates from Infisical to a directory on a Windows server over WinRM- The connection user must be able to write to the destination directory<Note>- Windows delivery runs on the Gateway because it uses WinRM message encryption, which lets a certificate travel confidentially over the default WinRM listener without a server certificate. This is the same zero-configuration posture most Windows hosts already ship with.+ Windows delivery runs on the Gateway, which reaches the host inside your network and runs the WinRM session on Infisical's behalf. WinRM connections use HTTPS, so the host must have a WinRM HTTPS listener configured.</Note>## Create a Windows Server Sync@@ -30,7 +30,7 @@ Deploy certificates from Infisical to a directory on a Windows server over WinRM3. Configure the **Destination**:- **Windows (WinRM) Connection**: The WinRM Connection used to reach the server.- - **Destination Directory**: The absolute Windows path where certificate files are written, either a drive path like `C:\certs` or a UNC share like `\\server\share\certs`. It is created if it does not exist. The path cannot contain `..` segments or consecutive separators.+ - **Destination Directory**: The absolute Windows drive path where certificate files are written, for example `C:\certs`. It is created if it does not exist. The path cannot contain `..` segments or consecutive separators.4. 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.@@ -103,7 +103,7 @@ When certificate removal is enabled and a certificate is removed from the sync,## Using Synced Certificates with IIS Centralized Certificate Store-IIS can serve a synced PKCS#12 certificate directly from a shared folder through the Centralized Certificate Store (CCS). To wire this up, set the sync to deliver into the CCS folder and make the two sides agree:+IIS can serve a synced PKCS#12 certificate directly from a local folder through the Centralized Certificate Store (CCS). To wire this up, set the sync to deliver into the CCS folder and make the two sides agree:<Note>- **Export format**: PKCS#12. CCS reads `.pfx` files only.@@ -117,7 +117,7 @@ These are IIS requirements, configured once on the Windows host (the CCS feature## FAQ<Accordion title="Which transport does the sync use?">- By default the connection uses the standard WinRM HTTP listener on port 5985 with NTLM message encryption. HTTPS on port 5986 is also supported for hosts that require it.+ The connection uses WinRM over HTTPS (typically port 5986), so the host must have a WinRM HTTPS listener configured. For a self-signed listener certificate, paste that certificate as the CA certificate on the connection so it can be verified; skip verification only when pinning is not possible.</Accordion><Accordion title="Can I import certificates from a Windows server back into Infisical?">diff --git a/docs/integrations/app-connections/winrm.mdx b/docs/integrations/app-connections/winrm.mdxindex 9cd5876014..05c4564cd1 100644--- a/docs/integrations/app-connections/winrm.mdx+++ b/docs/integrations/app-connections/winrm.mdx@@ -3,7 +3,7 @@ title: "Windows (WinRM) Connection"description: "Learn how to configure a Windows (WinRM) Connection for Infisical."----Infisical supports connecting to Windows hosts over WinRM to deliver certificates. Because WinRM message encryption runs in the Gateway, this connection always routes through an [Infisical Gateway](/documentation/platform/gateways/overview) inside your network.+Infisical supports connecting to Windows hosts over WinRM to deliver certificates. The connection always routes through an [Infisical Gateway](/documentation/platform/gateways/overview) inside your network, which reaches the host and runs the WinRM session on Infisical's behalf. WinRM connections use HTTPS.## Setup@@ -14,12 +14,12 @@ Infisical supports connecting to Windows hosts over WinRM to deliver certificateYou will need the following for the target Windows host:- **Host**: The DNS name (FQDN) or IP address of the Windows host.- - **Port**: The WinRM port. `5985` for HTTP with NTLM message encryption, `5986` for HTTPS.+ - **Port**: The WinRM HTTPS port (typically `5986`).- **Username**: A Windows login, either `DOMAIN\user` or `[email protected]`.- **Password**: The account password.<Note>- The account must be able to open a WinRM session and write to the destination directory used by the certificate sync.+ The host must have a WinRM HTTPS listener configured, and the account must be able to open a WinRM session and write to the destination directory used by the certificate sync.</Note></Step><Step title="Navigate to App Connections">@@ -33,10 +33,9 @@ Infisical supports connecting to Windows hosts over WinRM to deliver certificate- **Gateway**: The Gateway that can reach the Windows host. This is required.- **Host**: The DNS name or IP address of the Windows host.- - **Port**: The WinRM port.+ - **Port**: The WinRM HTTPS port (typically `5986`).- **Username** and **Password**: The Windows account credentials.- - **Transport**: Choose HTTP with NTLM message encryption on port 5985, or HTTPS on port 5986.- - **TLS Certificate Verification**: For HTTPS, choose whether to verify the listener certificate. Skip verification only for a self-signed listener.+ - **TLS Certificate Verification**: Verify with the system trust store, verify against a **CA certificate** you paste in (recommended for a self-signed listener, since it keeps server authentication), or skip verification. Skipping gives confidentiality but does not authenticate the server, so an on-path attacker is not prevented.Click **Connect to Windows (WinRM)** to validate and save your connection.</Step>@@ -63,10 +62,9 @@ Infisical supports connecting to Windows hosts over WinRM to deliver certificate"gatewayId": "3c90c3cc-0d44-4b50-8888-8dd25736052a","credentials": {"host": "win01.corp.example.com",- "port": 5985,+ "port": 5986,"username": "DOMAIN\\svc-infisical","password": "[PASSWORD]",- "useHttps": false,"insecure": false}}'@@ -77,11 +75,11 @@ Infisical supports connecting to Windows hosts over WinRM to deliver certificate## Transport<Note>- The default transport is the standard WinRM HTTP listener on port 5985 with NTLM message encryption. This keeps the certificate and key confidential without a server certificate on the host, which is the zero-configuration posture most Windows hosts ship with. HTTPS on port 5986 is supported for hosts that require it.+ WinRM connections use HTTPS (typically port `5986`), so the host must have a WinRM HTTPS listener configured. If the listener presents a self-signed certificate, paste that certificate as the CA certificate so it can be verified. Only skip verification when pinning a certificate is not possible; skipping protects confidentiality but not against an active on-path attacker.</Note>## FAQ<Accordion title="Why does this connection require a Gateway?">- WinRM message encryption must be performed by a component inside your network. The Gateway performs it, which lets a certificate travel confidentially over the default listener without a server certificate on every host.+ 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.</Accordion>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 9edbb01811..2d9b40db75 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@@ -31,14 +31,13 @@ const WindowsDestinationPathSchema = z.trim().min(1, "Destination path is required").max(4096, "Destination path is too long")- .refine((p) => /^([a-zA-Z]:\\|\\\\)/.test(p), {- message:- "Destination path must be an absolute Windows path (for example C:\\certs or \\\\server\\share)"+ .refine((p) => /^[a-zA-Z]:\\/.test(p), {+ message: "Destination path must be an absolute Windows drive path (for example C:\\certs)"}).refine((p) => !/(^|[\\/])\.\.([\\/]|$)/.test(p), {message: "Destination path must not contain '..'"})- .refine((p) => !/[\\/]{2,}/.test(p.startsWith("\\\\") ? p.slice(2) : p), {+ .refine((p) => !/[\\/]{2,}/.test(p), {message: "Destination path must not contain consecutive path separators"});diff --git a/frontend/src/hooks/api/appConnections/types/winrm-connection.ts b/frontend/src/hooks/api/appConnections/types/winrm-connection.tsindex ff221de11a..daeb014347 100644--- a/frontend/src/hooks/api/appConnections/types/winrm-connection.ts+++ b/frontend/src/hooks/api/appConnections/types/winrm-connection.ts@@ -12,7 +12,7 @@ export type TWinRMConnection = TRootAppConnection & { app: AppConnection.WinRM }port?: number;username: string;password: string;- useHttps?: boolean;+ caCertificate?: string;insecure?: boolean;};};diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/WinRMConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/WinRMConnectionForm.tsxindex 3cef968e32..6d38ceebe5 100644--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/WinRMConnectionForm.tsx+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/WinRMConnectionForm.tsx@@ -16,6 +16,7 @@ import {SelectItem,SelectTrigger,SelectValue,+ TextArea,Tooltip,TooltipContent,TooltipTrigger@@ -51,7 +52,7 @@ const formSchema = zport: z.coerce.number().int().min(1).max(65535),username: z.string().trim().min(1, "Username required"),password: z.string().min(1, "Password required"),- useHttps: z.boolean(),+ caCertificate: z.string().optional(),insecure: z.boolean()})})@@ -80,10 +81,10 @@ export const WinRMConnectionForm = ({ appConnection, onSubmit }: Props) => {gatewayPoolId: null,credentials: {host: "",- port: 5985,+ port: 5986,username: "",password: "",- useHttps: false,+ caCertificate: "",insecure: false}}@@ -93,7 +94,10 @@ export const WinRMConnectionForm = ({ appConnection, onSubmit }: Props) => {const gatewayId = watch("gatewayId");const gatewayPoolId = watch("gatewayPoolId");- const useHttps = watch("credentials.useHttps");+ const insecure = watch("credentials.insecure");+ const caCertificate = watch("credentials.caCertificate");+ // eslint-disable-next-line no-nested-ternary+ const tlsMode = insecure ? "skip" : caCertificate ? "ca" : "verify";return (<FormProvider {...form}>@@ -243,62 +247,51 @@ export const WinRMConnectionForm = ({ appConnection, onSubmit }: Props) => {)}/></div>- <Controller- name="credentials.useHttps"- control={control}- render={({ field: { value }, fieldState: { error } }) => (- <Field className="mb-4">- <FieldLabel>Transport</FieldLabel>- <Select- value={value ? "https" : "http"}- onValueChange={(val) => {- const https = val === "https";- setValue("credentials.useHttps", https, { shouldDirty: true });- setValue("credentials.port", https ? 5986 : 5985, { shouldDirty: true });- if (!https) {- setValue("credentials.insecure", false, { shouldDirty: true });- }- }}- >- <SelectTrigger className="w-full" isError={Boolean(error)}>- <SelectValue />- </SelectTrigger>- <SelectContent position="popper">- <SelectItem value="http">- HTTP with NTLM message encryption (port 5985)- </SelectItem>- <SelectItem value="https">HTTPS (port 5986)</SelectItem>- </SelectContent>- </Select>- <FieldDescription>- HTTP uses NTLM message encryption and needs no server certificate. HTTPS requires a- WinRM HTTPS listener on the host.- </FieldDescription>- <FieldError errors={[error]} />- </Field>- )}- />- {useHttps && (+ <Field className="mb-4">+ <FieldLabel>TLS Certificate Verification</FieldLabel>+ <Select+ value={tlsMode}+ onValueChange={(val) => {+ if (val === "skip") {+ setValue("credentials.insecure", true, { shouldDirty: true });+ setValue("credentials.caCertificate", "", { shouldDirty: true });+ } else if (val === "ca") {+ setValue("credentials.insecure", false, { shouldDirty: true });+ } else {+ setValue("credentials.insecure", false, { shouldDirty: true });+ setValue("credentials.caCertificate", "", { shouldDirty: true });+ }+ }}+ >+ <SelectTrigger className="w-full">+ <SelectValue />+ </SelectTrigger>+ <SelectContent position="popper">+ <SelectItem value="verify">Verify with system trust store</SelectItem>+ <SelectItem value="ca">Verify with a CA certificate</SelectItem>+ <SelectItem value="skip">Skip verification (self-signed listener)</SelectItem>+ </SelectContent>+ </Select>+ <FieldDescription>+ WinRM connections use HTTPS. For a self-signed listener, pin its CA certificate to keep+ server authentication. Skip verification only as a last resort: it gives confidentiality+ but does not authenticate the server.+ </FieldDescription>+ </Field>+ {tlsMode === "ca" && (<Controller- name="credentials.insecure"+ name="credentials.caCertificate"control={control}- render={({ field: { value }, fieldState: { error } }) => (+ render={({ field, fieldState: { error } }) => (<Field className="mb-4">- <FieldLabel>TLS Certificate Verification</FieldLabel>- <Select- value={value ? "skip" : "verify"}- onValueChange={(val) =>- setValue("credentials.insecure", val === "skip", { shouldDirty: true })- }- >- <SelectTrigger className="w-full" isError={Boolean(error)}>- <SelectValue />- </SelectTrigger>- <SelectContent position="popper">- <SelectItem value="verify">Verify certificate</SelectItem>- <SelectItem value="skip">Skip verification (self-signed listener)</SelectItem>- </SelectContent>- </Select>+ <FieldLabel htmlFor="caCertificate">CA Certificate (PEM)</FieldLabel>+ <TextArea+ id="caCertificate"+ {...field}+ placeholder={"-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----"}+ rows={5}+ isError={Boolean(error?.message)}+ /><FieldError errors={[error]} /></Field>)}