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
Fix HTTP/HTTPS winrm
Carlos Monastyrski41310839b133
diff --git a/backend/src/lib/gateway-v2/winrm-rpc.ts b/backend/src/lib/gateway-v2/winrm-rpc.tsindex c209a24941..46ec1cddd0 100644--- a/backend/src/lib/gateway-v2/winrm-rpc.ts+++ b/backend/src/lib/gateway-v2/winrm-rpc.ts@@ -5,6 +5,7 @@ import { logger } from "@app/lib/logger";export type WinRmRpcEndpoint = "/v1/test" | "/v1/deliver" | "/v1/remove";export type WinRmTransportParams = {+ useHttps?: boolean;insecure?: boolean;caCertificate?: string;};diff --git a/backend/src/services/app-connection/winrm/winrm-connection-fns.ts b/backend/src/services/app-connection/winrm/winrm-connection-fns.tsindex 340245d727..e84a14bbb2 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,9 @@ export type TWinRMCredentials = {port: number;username: string;password: string;- insecure?: boolean;- caCertificate?: string;+ sslEnabled?: boolean;+ sslRejectUnauthorized?: boolean;+ sslCertificate?: string;};export const getWinRMConnectionListItem = () => ({@@ -88,8 +89,11 @@ export const executeWinRMGatewayOperation = async <T>(username: args.credentials.username,password: args.credentials.password,params: {- insecure: args.credentials.caCertificate ? false : (args.credentials.insecure ?? false),- ...(args.credentials.caCertificate ? { caCertificate: args.credentials.caCertificate } : {}),+ useHttps: args.credentials.sslEnabled ?? false,+ insecure: args.credentials.sslEnabled ? args.credentials.sslRejectUnauthorized === false : false,+ ...(args.credentials.sslEnabled && args.credentials.sslCertificate+ ? { caCertificate: args.credentials.sslCertificate }+ : {}),...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 7891088ba4..209f725b92 100644--- a/backend/src/services/app-connection/winrm/winrm-connection-schemas.ts+++ b/backend/src/services/app-connection/winrm/winrm-connection-schemas.ts@@ -17,7 +17,13 @@ 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(5986).describe("The WinRM HTTPS port (typically 5986)."),+ port: z.coerce+ .number()+ .int()+ .min(1)+ .max(65535)+ .default(5985)+ .describe("The WinRM port. 5985 for HTTP with NTLM message encryption, 5986 for HTTPS."),username: z.string().trim()@@ -25,20 +31,17 @@ 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."),- caCertificate: z+ sslEnabled: z+ .boolean()+ .default(false)+ .describe("Connect over HTTPS. When disabled, HTTP with NTLM message encryption is used."),+ sslRejectUnauthorized: z.boolean().default(true).describe("Verify the listener's TLS certificate (HTTPS only)."),+ sslCertificate: 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. Gives confidentiality but not server authentication; prefer pinning a CA certificate for self-signed listeners."- )+ .describe("CA certificate (PEM) used to verify a self-signed WinRM HTTPS listener (HTTPS only).")});const BaseWinRMConnectionSchema = BaseAppConnectionSchema.extend({ app: z.literal(AppConnection.WinRM) });@@ -56,8 +59,9 @@ export const SanitizedWinRMConnectionSchema = z.discriminatedUnion("method", [host: true,port: true,username: true,- caCertificate: true,- insecure: true+ sslEnabled: true,+ sslRejectUnauthorized: true,+ sslCertificate: true})}).describe(JSON.stringify({ title: `${APP_CONNECTION_NAME_MAP[AppConnection.WinRM]} (Username and Password)` }))]);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 4f82e18636..4b9e1d9c4b 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,12 @@ const buildWinRMTarget = (pkiSync: TPkiSyncWithCredentials) => {const winrmCredentials: TWinRMCredentials = {host: credentials.host,- port: credentials.port ?? 5986,+ port: credentials.port ?? 5985,username: credentials.username,password: credentials.password,- insecure: credentials.insecure,- caCertificate: credentials.caCertificate+ sslEnabled: credentials.sslEnabled,+ sslRejectUnauthorized: credentials.sslRejectUnauthorized,+ sslCertificate: credentials.sslCertificate};return {diff --git a/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx b/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdxindex 973c06f8a2..83387b33a5 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, 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.+ Windows delivery runs on the Gateway, which reaches the host inside your network and runs the WinRM session on Infisical's behalf. By default it uses HTTP with NTLM 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. HTTPS is also supported.</Note>## Create a Windows Server Sync@@ -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?">- 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.+ 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?">diff --git a/docs/integrations/app-connections/winrm.mdx b/docs/integrations/app-connections/winrm.mdxindex 05c4564cd1..f8889c9d46 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. 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.+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. By default it uses HTTP with NTLM message encryption, which keeps the certificate and key confidential without a server certificate. HTTPS is also supported.## 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 HTTPS port (typically `5986`).+ - **Port**: The WinRM port. `5985` for HTTP with NTLM message encryption, `5986` for HTTPS.- **Username**: A Windows login, either `DOMAIN\user` or `[email protected]`.- **Password**: The account password.<Note>- 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.+ The account must be able to open a WinRM session and write to the destination directory used by the certificate sync. HTTP with NTLM message encryption works against the default WinRM listener with no extra setup. HTTPS additionally requires a WinRM HTTPS listener on the host.</Note></Step><Step title="Navigate to App Connections">@@ -32,10 +32,11 @@ Infisical supports connecting to Windows hosts over WinRM to deliver certificateFill in the connection form:- **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 HTTPS port (typically `5986`).+ - **Host** and **Port**: The Windows host and WinRM port (5985 for HTTP, 5986 for HTTPS).- **Username** and **Password**: The Windows account credentials.- - **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.+ - **Enable SSL**: Off (default) uses HTTP with NTLM message encryption, which needs no server certificate. On uses HTTPS.+ - **SSL Certificate** (HTTPS only): Optional CA certificate (PEM). Leave empty to verify the listener against the system trust store, or paste the listener's certificate to verify a self-signed WinRM HTTPS listener.+ - **Reject Unauthorized** (HTTPS only): When on (default), Infisical only connects if the listener presents a valid, trusted certificate.Click **Connect to Windows (WinRM)** to validate and save your connection.</Step>@@ -62,10 +63,11 @@ Infisical supports connecting to Windows hosts over WinRM to deliver certificate"gatewayId": "3c90c3cc-0d44-4b50-8888-8dd25736052a","credentials": {"host": "win01.corp.example.com",- "port": 5986,+ "port": 5985,"username": "DOMAIN\\svc-infisical","password": "[PASSWORD]",- "insecure": false+ "sslEnabled": false,+ "sslRejectUnauthorized": true}}'```@@ -75,7 +77,7 @@ Infisical supports connecting to Windows hosts over WinRM to deliver certificate## Transport<Note>- 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.+ 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>## FAQdiff --git a/frontend/src/hooks/api/appConnections/types/winrm-connection.ts b/frontend/src/hooks/api/appConnections/types/winrm-connection.tsindex daeb014347..e98a15250e 100644--- a/frontend/src/hooks/api/appConnections/types/winrm-connection.ts+++ b/frontend/src/hooks/api/appConnections/types/winrm-connection.ts@@ -12,7 +12,8 @@ export type TWinRMConnection = TRootAppConnection & { app: AppConnection.WinRM }port?: number;username: string;password: string;- caCertificate?: string;- insecure?: boolean;+ sslEnabled?: boolean;+ sslRejectUnauthorized?: boolean;+ sslCertificate?: string;};};diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/WinRMConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/WinRMConnectionForm.tsxindex 6d38ceebe5..345ae84534 100644--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/WinRMConnectionForm.tsx+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/WinRMConnectionForm.tsx@@ -6,16 +6,19 @@ import { z } from "zod";import { OrgPermissionCan } from "@app/components/permissions";import {Field,+ FieldContent,FieldDescription,FieldError,FieldLabel,Input,+ Label,SecretInput,Select,SelectContent,SelectItem,SelectTrigger,SelectValue,+ Switch,TextArea,Tooltip,TooltipContent,@@ -52,8 +55,9 @@ 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"),- caCertificate: z.string().optional(),- insecure: z.boolean()+ sslEnabled: z.boolean(),+ sslRejectUnauthorized: z.boolean(),+ sslCertificate: z.string().optional()})})])@@ -81,11 +85,12 @@ export const WinRMConnectionForm = ({ appConnection, onSubmit }: Props) => {gatewayPoolId: null,credentials: {host: "",- port: 5986,+ port: 5985,username: "",password: "",- caCertificate: "",- insecure: false+ sslEnabled: false,+ sslRejectUnauthorized: true,+ sslCertificate: ""}}});@@ -94,10 +99,7 @@ export const WinRMConnectionForm = ({ appConnection, onSubmit }: Props) => {const gatewayId = watch("gatewayId");const gatewayPoolId = watch("gatewayPoolId");- const insecure = watch("credentials.insecure");- const caCertificate = watch("credentials.caCertificate");- // eslint-disable-next-line no-nested-ternary- const tlsMode = insecure ? "skip" : caCertificate ? "ca" : "verify";+ const sslEnabled = watch("credentials.sslEnabled");return (<FormProvider {...form}>@@ -247,56 +249,73 @@ export const WinRMConnectionForm = ({ appConnection, onSubmit }: Props) => {)}/></div>- <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.caCertificate"- control={control}- render={({ field, fieldState: { error } }) => (- <Field className="mb-4">- <FieldLabel htmlFor="caCertificate">CA Certificate (PEM)</FieldLabel>- <TextArea- id="caCertificate"- {...field}- placeholder={"-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----"}- rows={5}- isError={Boolean(error?.message)}+ <Controller+ name="credentials.sslEnabled"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <Field className="mb-4">+ <Field orientation="horizontal">+ <FieldContent>+ <Label htmlFor="ssl-enabled">Enable SSL</Label>+ <FieldDescription>+ Connect over HTTPS. When disabled, HTTP with NTLM message encryption is used and+ no server certificate is required.+ </FieldDescription>+ </FieldContent>+ <Switch id="ssl-enabled" checked={value} onCheckedChange={onChange} />+ </Field>+ <FieldError errors={[error]} />+ </Field>+ )}+ />+ <Controller+ name="credentials.sslCertificate"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <Field className={sslEnabled ? "mb-4" : "mb-4 opacity-50"}>+ <FieldLabel htmlFor="ssl-certificate">+ SSL Certificate <span className="text-mineshaft-400">(optional)</span>+ </FieldLabel>+ <TextArea+ id="ssl-certificate"+ {...field}+ disabled={!sslEnabled}+ placeholder={"-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----"}+ rows={5}+ isError={Boolean(error?.message)}+ />+ <FieldDescription>+ Leave empty to verify against the system trust store, or paste the listener's+ certificate to verify a self-signed WinRM HTTPS listener.+ </FieldDescription>+ <FieldError errors={[error]} />+ </Field>+ )}+ />+ <Controller+ name="credentials.sslRejectUnauthorized"+ control={control}+ render={({ field: { value, onChange }, fieldState: { error } }) => (+ <Field className={sslEnabled ? "mb-4" : "mb-4 opacity-50"}>+ <Field orientation="horizontal">+ <FieldContent>+ <Label htmlFor="ssl-reject-unauthorized">Reject Unauthorized</Label>+ <FieldDescription>+ If enabled, Infisical only connects when the listener presents a valid, trusted+ certificate.+ </FieldDescription>+ </FieldContent>+ <Switch+ id="ssl-reject-unauthorized"+ checked={sslEnabled ? value : false}+ onCheckedChange={onChange}+ disabled={!sslEnabled}/>- <FieldError errors={[error]} /></Field>- )}- />- )}+ <FieldError errors={[error]} />+ </Field>+ )}+ /><AppConnectionFormFootersubmitLabel={isUpdate ? "Update Credentials" : "Connect to Windows (WinRM)"}/>