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
docs: linux and windows doc improvements
Sheen Capadngande6b078410c4
diff --git a/docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdx b/docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdxindex 885bceeb42..2aa4eb0acb 100644--- a/docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdx+++ b/docs/documentation/platform/pki/applications/certificate-syncs/linux-server.mdx@@ -4,10 +4,9 @@ sidebarTitle: "Linux Server"description: "Deploy certificates to Linux servers over SSH."----import PostSyncCommandVariables from "/snippets/documentation/platform/pki/applications/certificate-syncs/post-sync-command-variables.mdx";-import PostSyncCommandFlow from "/snippets/documentation/platform/pki/applications/certificate-syncs/post-sync-command-flow.mdx";-import HealthCheckVariables from "/snippets/documentation/platform/pki/applications/certificate-syncs/health-check-variables.mdx";+import CommandVariables from "/snippets/documentation/platform/pki/applications/certificate-syncs/command-variables.mdx";import HealthCheckFlow from "/snippets/documentation/platform/pki/applications/certificate-syncs/health-check-flow.mdx";+import PostSyncCommandFlow from "/snippets/documentation/platform/pki/applications/certificate-syncs/post-sync-command-flow.mdx";Deploy certificates from Infisical to a directory on a Linux server over SSH. Files are written atomically over SFTP so a reader never sees a partially written certificate or key.@@ -20,7 +19,7 @@ Deploy certificates from Infisical to a directory on a Linux server over SSH. Fi- An [SSH Connection](/integrations/app-connections/ssh) with access to the target server- The destination directory must already exist on the server and the connection user must be able to write to it- The server must be reachable from Infisical, either directly or through an [Infisical Gateway](/documentation/platform/gateways/overview)-- A Gateway is required to use a [health check](#health-checks) or a [post-sync command](#post-sync-commands), because the Gateway is what executes them. It must be running Infisical CLI v0.43.120 or later+- A Gateway is required to use a [health check](#health-check) or a [post-sync command](#post-sync-command), because the Gateway is what executes them. It must be running Infisical CLI v0.43.120 or later## Create a Linux Server sync@@ -48,8 +47,8 @@ Deploy certificates from Infisical to a directory on a Linux server over SSH. Fi- **Auto-Sync Enabled**: Automatically sync certificates when changes occur.5. Configure the **Commands**, or leave them empty:- - **Health check**: A command run on the server before any certificate is written, to confirm the host is ready, for example `test -w /etc/ssl/certs`. A non-zero exit stops the sync, so nothing is delivered. See [health checks](#health-checks).- - **Post-sync command**: A command run on the server after the sync delivers a certificate, so the service that uses it picks up the new file, for example `sudo systemctl reload nginx`. See [Post-Sync Commands](#post-sync-commands).+ - **Health check**: A command run on the server before any certificate is written, to confirm the host is ready, for example `test -w /etc/ssl/certs`. A non-zero exit stops the sync, so nothing is delivered. See [health check](#health-check).+ - **Post-sync command**: A command run on the server after the sync delivers a certificate, so the service that uses it picks up the new file, for example `sudo systemctl reload nginx`. See [post-sync command](#post-sync-command).6. Configure the **Details**:- **Name**: The name of your sync.@@ -115,24 +114,55 @@ PKCS#12When 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.-## Health checks+## Commands++A sync can run two optional commands on the target server, in that server's own shell:++- A **health check** runs before any certificate is written and gates the delivery, for example `test -w /etc/ssl/certs`.+- A **post-sync command** runs after the delivery has finished, so the service that uses the certificate picks up the new file, for example `sudo systemctl reload nginx`.++Set each on the sync's **Commands** step. Leaving a field empty means nothing runs, so neither has a separate toggle. Both accept a whole script, so several steps can run in one go: put each on its own line, or chain them with `&&`.++<Note>+ Your [Infisical Gateway](/documentation/platform/gateways/overview) runs both commands, never Infisical. The sync's SSH Connection must therefore use a gateway, otherwise the command is rejected when you save the sync.++ The Gateway must be running Infisical CLI **v0.43.120 or later**. Earlier Gateways either cannot run the command at all or cannot unlock an SSH Connection's passphrase-protected private key, so the command fails. Run `infisical --version` on the Gateway host to check, and see [Gateway deployment](/documentation/platform/gateways/gateway-deployment) for how to upgrade.+</Note>++### Available variables++<CommandVariables />++### Length limit++Each command is limited to 8192 characters, counted as you write it, before variables are substituted. For anything longer, put the logic in a script on the server and have the command call that script.++### Least privilege++Both commands run as the account the SSH Connection authenticates with, so constraining that account bounds what either can do. A service reload does not need root. Grant the connection user a `sudoers` rule for that one command instead:++```text+svc-infisical ALL=(root) NOPASSWD: /usr/bin/systemctl reload nginx+```++Anyone who can edit the sync can change either command, so treat edit access to these syncs as access to the target server.++<Warning>+ The rendered command is visible in the target server's process table while it runs. This only matters if you reference `{{pkcs12Password}}`, and only to accounts that already have a shell on the server the sync writes private keys to.+</Warning>++### Health checkA sync can only tell you the host was not ready once it has already tried. If the destination directory was renamed or the service that owns it is stopped, you find out from a failed sync, and on a renewal that is the day the certificate was going to expire anyway.-A health check moves that discovery earlier. It is one command that runs on the target server before any certificate is written. If it exits non-zero, the sync stops there: no files are delivered, no removals happen, and no post-sync command runs. Leaving the field empty means nothing runs, so there is no separate toggle.+A health check moves that discovery earlier. It runs on the target server before any certificate is written. If it exits non-zero, the sync stops there: no files are delivered, no removals happen, and no post-sync command runs.The same check also runs on its own once a day, so a host that stops being ready between syncs is reported when it happens rather than at the next renewal.Write a check that answers a question rather than one that changes something. `test -w /etc/ssl/certs` and `systemctl is-active nginx` are good checks. Creating the directory or starting the service is work for the post-sync command.-<Note>- Your [Infisical Gateway](/documentation/platform/gateways/overview) runs the check, never Infisical. The sync's SSH Connection must therefore use a gateway, otherwise the check is rejected when you save the sync.-</Note>-<HealthCheckFlow />-### Setting a check-<Steps><Step title="Open the sync's Commands step">Edit the sync and select **Commands**.@@ -147,61 +177,28 @@ Write a check that answers a question rather than one that changes something. `ttest ! -e {{certificatePath}} || test -w {{certificatePath}}systemctl is-active --quiet nginx```- </Step>- <Step title="Save and trigger a sync">- Save the sync, then trigger it. If the check fails, the sync fails without delivering, and the reason appears as the sync's last error.- </Step>-</Steps>--### Available variables--<HealthCheckVariables />--### Length limit-A check is limited to 8192 characters, counted as you write it, before variables are substituted. For anything longer, put the logic in a script on the server and call that script.+ To check every certificate the run would write instead of one, loop over `{{certificateFiles}}`:-### Health check FAQ+ ```bash+ echo {{certificateFiles}} | while read -r file; do test -w "$(dirname "$file")"; done+ ```+ </Step>+ <Step title="Test it, then save the sync">+ **Test check** runs the check against the host straight away, so you can see the result without waiting for a sync. It resolves variables against the certificates linked to the sync, so it works once at least one is selected and tells you if none is. `{{pkcs12Password}}` is the exception: the export password only exists once a saved sync delivers a certificate, so a test always rejects it.-<AccordionGroup>- <Accordion title="When exactly does the check run?">- Before anything else in a sync run, including before Infisical opens the SFTP session it would write with. It also runs once a day on its own, whether or not a sync is due.- </Accordion>- <Accordion title="What happens when the check fails?">- The sync is marked failed and the reason appears as the sync's last error. Every certificate in the run is reported as skipped with that same reason, so it is clear nothing reached the host. Files already on the server from an earlier run are left exactly as they are, because the sync never wrote or deleted anything.- </Accordion>- <Accordion title="Where do I see the result of the daily check?">- A failing daily check records the failure and its reason against the sync's health check, shown as Last Checked on the sync's page, and notifies the application's administrators. It does not change the sync's own status, which continues to report the last delivery. Either way the run is recorded in the sync's logs with the command and the first part of its output.- </Accordion>- <Accordion title="Is there a time limit?">- Yes, 15 seconds, and a check that runs out of time counts as a failure. The limit is deliberately much shorter than the post-sync command's, because the check gates delivery: a host that cannot answer a readiness question in fifteen seconds is itself the problem worth reporting. Keep the check to a question that is cheap to answer.- </Accordion>- <Accordion title="Does a failed check get retried?">- Not within the run. A host that is not ready is usually not ready a few seconds later either, so retrying only delays the report. The next sync or the next daily check is the retry.- </Accordion>- <Accordion title="Can I use it to prepare the host instead of just checking it?">- You can, since it is a free-text command, but prefer not to. A check that also does work runs before every sync and has fifteen seconds to finish, and if it fails halfway you have changed the host and delivered nothing. Keep preparation in the post-sync command, or in a script the check only verifies the result of.- </Accordion>-</AccordionGroup>+ Save the sync once the check passes. On a real run, a failing check fails the sync without delivering anything, and the reason appears as the sync's last error.+ </Step>+</Steps>-## Post-sync commands+### Post-sync commandDelivering a certificate file does not make the service use it. NGINX keeps serving the old certificate until something reloads it. A post-sync command is that last step, run for you right after the files land.-Set one command on the sync. It runs on the target server, in that server's own shell, once per sync run that delivers at least one file. Leaving the field empty means nothing runs, so there is no separate toggle. If a sync run does not complete, Infisical may attempt it again and the command runs with it, so prefer a command that is safe to run more than once.--The field accepts a whole script, so several steps can run in one go: put each on its own line, or chain them with `&&`.--<Note>- Your [Infisical Gateway](/documentation/platform/gateways/overview) runs the command, never Infisical. The sync's SSH Connection must therefore use a gateway, otherwise the command is rejected when you save the sync.-- The Gateway must be running Infisical CLI **v0.43.120 or later**. Earlier Gateways either cannot run the command at all or cannot unlock an SSH Connection's passphrase-protected private key, so the command fails. Run `infisical --version` on the Gateway host to check, and see [Gateway deployment](/documentation/platform/gateways/gateway-deployment) for how to upgrade.-</Note>+It runs once per sync run that delivers at least one file. If a sync run does not complete, Infisical may attempt it again and the command runs with it, so prefer a command that is safe to run more than once.<PostSyncCommandFlow />-### Setting a command-<Steps><Step title="Open the sync's Commands step">Edit the sync and select **Commands**.@@ -218,27 +215,23 @@ The field accepts a whole script, so several steps can run in one go: put each o</Step></Steps>-### Available variables--<PostSyncCommandVariables />--### Length limit--A command is limited to 8192 characters, counted as you write it, before variables are substituted. For anything longer, put the logic in a script on the server and call that script.--### Post-sync command FAQ+### Command FAQ<AccordionGroup>- <Accordion title="When exactly does the command run?">- After every file in the run has been delivered and after any removals, so the server is in its final state before the service reloads. A run that delivers nothing runs nothing. Renewals, adding a certificate, and a manual trigger all deliver files, so all three run the command. Removing a certificate from the sync does not.+ <Accordion title="When exactly does each command run?">+ The health check runs before anything else in a sync run, including before Infisical opens the SFTP session it would write with. It also runs once a day on its own, whether or not a sync is due.++ The post-sync command runs after every file in the run has been delivered and after any removals, so the server is in its final state before the service reloads. A run that delivers nothing runs nothing. Renewals, adding a certificate, and a manual trigger all deliver files, so all three run the command. Removing a certificate from the sync does not.</Accordion>- <Accordion title="What happens if the command fails?">- The sync is marked failed and the reason appears as the sync's last error. The delivered files stay in place, because they were written before the command ran. A command that fails is reported, not repeated.+ <Accordion title="What happens when a command fails?">+ Either way the sync is marked failed and the reason appears as the sync's last error. A command that fails is reported, not repeated.++ What is left on the host differs. When the **health check** fails, every certificate in the run is reported as skipped with that same reason, so it is clear nothing reached the host, and files already on the server from an earlier run are left exactly as they are, because the sync never wrote or deleted anything. When the **post-sync command** fails, the delivered files stay in place, because they were written before the command ran.</Accordion><Accordion title="Can I run several commands, and what happens if one of them fails?">- Yes. Write one per line, or chain them with `&&`.+ Yes, in either field. Write one per line, or chain them with `&&`.- By default the shell only reports the **last** line's exit status, so an earlier line that fails is not noticed and the sync still reports success. Start the script with `set -e` so the first failure stops it and fails the sync:+ By default the shell only reports the **last** line's exit status, so an earlier line that fails is not noticed and the command counts as having succeeded. Start the script with `set -e` so the first failure stops it and fails the sync:```bashset -e@@ -247,28 +240,25 @@ A command is limited to 8192 characters, counted as you write it, before variablsystemctl reload nginx```</Accordion>- <Accordion title="Can the command run twice for the same certificate?">- Yes, in some cases. If a sync run does not complete, Infisical may attempt it again, and the command runs as part of that attempt. Prefer a command that is safe to run more than once. A service reload or restart is.- </Accordion><Accordion title="Is there a time limit?">- Yes, 30 seconds, enforced by the gateway. A command that needs longer should start the work in the background or live in a script on the server.+ Yes, and it differs by command: 15 seconds for the health check, 30 seconds for the post-sync command. Both are enforced by the Gateway, and running out of time counts as a failure.++ The check's limit is deliberately much shorter, because the check gates delivery: a host that cannot answer a readiness question in fifteen seconds is itself the problem worth reporting. Keep the check to a question that is cheap to answer, and give a post-sync command that needs longer than thirty seconds a script on the server that starts the work in the background.+ </Accordion>+ <Accordion title="Can a command run twice for the same certificate?">+ Yes, in some cases. If a sync run does not complete, Infisical may attempt it again, and both commands run as part of that attempt. Prefer commands that are safe to run more than once. A service reload or restart is.+ </Accordion>+ <Accordion title="Does a failed health check get retried?">+ Not within the run. A host that is not ready is usually not ready a few seconds later either, so retrying only delays the report. The next sync or the next daily check is the retry.+ </Accordion>+ <Accordion title="Where do I see the result of the daily health check?">+ A failing daily check records the failure and its reason against the sync's health check, shown as Last Checked on the sync's page, and notifies the application's administrators. It does not change the sync's own status, which continues to report the last delivery. Either way the run is recorded in the sync's logs with the command and the first part of its output.+ </Accordion>+ <Accordion title="Can I use the health check to prepare the host instead of just checking it?">+ You can, since it is a free-text command, but prefer not to. A check that also does work runs before every sync and has fifteen seconds to finish, and if it fails halfway you have changed the host and delivered nothing. Keep preparation in the post-sync command, or in a script the check only verifies the result of.</Accordion></AccordionGroup>-### Least privilege--Both the health check and the post-sync command run as the account the SSH Connection authenticates with, so constraining that account bounds what either can do. A service reload does not need root. Grant the connection user a `sudoers` rule for that one command instead:--```text-svc-infisical ALL=(root) NOPASSWD: /usr/bin/systemctl reload nginx-```--Anyone who can edit the sync can change either command, so treat edit access to these syncs as access to the target server. Setting them is a separate permission from editing the sync, so a role can be allowed to change a sync's destination and options without being allowed to change what it runs on the host.--<Warning>- The rendered command is visible in the target server's process table while it runs. This only matters if you reference `{{pkcs12Password}}`, and only to accounts that already have a shell on the server the sync writes private keys to.-</Warning>-## Removing certificatesWhen certificate removal is enabled and a certificate is removed from the sync, revoked, or expired, Infisical deletes exactly the files it delivered for that certificate.diff --git a/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx b/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdxindex 3cdbf81f0a..f5b62af60c 100644--- a/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx+++ b/docs/documentation/platform/pki/applications/certificate-syncs/windows-server.mdx@@ -4,10 +4,9 @@ sidebarTitle: "Windows Server"description: "Deploy certificates to Windows servers over WinRM."----import PostSyncCommandVariables from "/snippets/documentation/platform/pki/applications/certificate-syncs/post-sync-command-variables.mdx";-import PostSyncCommandFlow from "/snippets/documentation/platform/pki/applications/certificate-syncs/post-sync-command-flow.mdx";-import HealthCheckVariables from "/snippets/documentation/platform/pki/applications/certificate-syncs/health-check-variables.mdx";+import CommandVariables from "/snippets/documentation/platform/pki/applications/certificate-syncs/command-variables.mdx";import HealthCheckFlow from "/snippets/documentation/platform/pki/applications/certificate-syncs/health-check-flow.mdx";+import PostSyncCommandFlow from "/snippets/documentation/platform/pki/applications/certificate-syncs/post-sync-command-flow.mdx";Deploy certificates from Infisical to a directory on a Windows server over WinRM. Files are written atomically so a reader never sees a partially written certificate or key.@@ -18,7 +17,7 @@ Deploy certificates from Infisical to a directory on a Windows server over WinRM## Prerequisites- A [Windows (WinRM) Connection](/integrations/app-connections/winrm) with access to the target server-- An [Infisical Gateway](/documentation/platform/gateways/overview) that can reach the server. Windows delivery always runs through the Gateway. A [post-sync command](#post-sync-commands) additionally needs the Gateway to be running Infisical CLI v0.43.120 or later.+- An [Infisical Gateway](/documentation/platform/gateways/overview) that can reach the server. Windows delivery always runs through the Gateway. A [post-sync command](#post-sync-command) additionally needs the Gateway to be running Infisical CLI v0.43.120 or later.- The connection user must be able to write to the destination directory<Note>@@ -50,8 +49,8 @@ Deploy certificates from Infisical to a directory on a Windows server over WinRM- **Auto-Sync Enabled**: Automatically sync certificates when changes occur.5. Configure the **Commands**, or leave them empty:- - **Health check**: A PowerShell command run on the server before any certificate is written, to confirm the host is ready, for example `Get-Service W3SVC | Where-Object Status -ne 'Running' | ForEach-Object { throw "W3SVC is not running" }`. A failure stops the sync, so nothing is delivered. See [health checks](#health-checks).- - **Post-sync command**: A PowerShell command run on the server after the sync delivers a certificate, so the service that uses it picks up the new file, for example `Restart-Service -Name "W3SVC"`. See [Post-Sync Commands](#post-sync-commands).+ - **Health check**: A PowerShell command run on the server before any certificate is written, to confirm the host is ready, for example `Get-Service W3SVC | Where-Object Status -ne 'Running' | ForEach-Object { throw "W3SVC is not running" }`. A failure stops the sync, so nothing is delivered. See [health check](#health-check).+ - **Post-sync command**: A PowerShell command run on the server after the sync delivers a certificate, so the service that uses it picks up the new file, for example `Restart-Service -Name "W3SVC"`. See [post-sync command](#post-sync-command).6. Configure the **Details**:- **Name**: The name of your sync.@@ -123,11 +122,44 @@ When syncing certificates, Infisical asks the Gateway to open a WinRM session toWhen certificate removal is enabled and a certificate is removed from the sync, revoked, or expired, Infisical deletes exactly the files it delivered for that certificate.-## Health checks+## Commands++A sync can run two optional commands as PowerShell on the target server:++- A **health check** runs before any certificate is written and gates the delivery, for example `if ((Get-Service W3SVC).Status -ne "Running") { throw "W3SVC is not running" }`.+- A **post-sync command** runs after the delivery has finished, so the service that uses the certificate picks up the new file, for example `Restart-Service -Name W3SVC`.++Set each on the sync's **Commands** step. Leaving a field empty means nothing runs, so neither has a separate toggle. Both accept a whole script, so several steps can run in one go: put each on its own line. Both run with `$ErrorActionPreference` set to `Stop`, so a failing cmdlet is enough to fail the command.++<Note>+ Your Gateway runs both commands, never Infisical. A WinRM Connection already requires a gateway, so nothing extra is needed here.++ The Gateway must be running Infisical CLI **v0.43.120 or later**. An earlier Gateway has no PowerShell run-command endpoint and rejects the request. A command longer than 2048 characters needs **v0.43.124 or later**, because earlier Gateways cap it at 2048 and reject the sync even though the form accepted the command. Run `infisical --version` on the Gateway host to check, and see [Gateway deployment](/documentation/platform/gateways/gateway-deployment) for how to upgrade.+</Note>++### Available variables++<CommandVariables />++### Length limit++Each command is limited to 8192 characters, counted as you write it, before variables are substituted. For anything longer, put the logic in a script file on the server and have the command call that script.++Going past 2048 characters requires a Gateway on Infisical CLI v0.43.124 or later. See the Gateway version note above.++### Least privilege++Both commands run as the account the WinRM Connection authenticates with, so constraining that account bounds what either can do. Restarting one service does not need an administrator. Grant the connection account start and stop rights on that single service instead of making it a local administrator.++Binding a certificate to an HTTPS port in IIS is the exception: HTTP.sys requires a local administrator and the right cannot be delegated. Because a local administrator can do anything on the host, handle that case with a dedicated, clearly labeled sync rather than raising the privileges of a sync that only needs to deliver files and restart a service. Infisical does not block an administrator credential on a standard sync, so this is a recommendation you enforce with how you configure the connection.++Anyone who can edit the sync can change either command, so treat edit access to these syncs as access to the target server.++### Health checkA sync can only tell you the host was not ready once it has already tried. If the destination folder was renamed or the service that owns the certificate is stopped, you find out from a failed sync, and on a renewal that is the day the certificate was going to expire anyway.-A health check moves that discovery earlier. It is one PowerShell command that the Gateway runs on the target server before any certificate is written. If it fails, the sync stops there: no files are delivered, no removals happen, and no post-sync command runs. Leaving the field empty means nothing runs, so there is no separate toggle.+A health check moves that discovery earlier. The Gateway runs it on the target server before any certificate is written. If it fails, the sync stops there: no files are delivered, no removals happen, and no post-sync command runs.The same check also runs on its own once a day, so a host that stops being ready between syncs is reported when it happens rather than at the next renewal.@@ -135,81 +167,39 @@ Write a check that answers a question rather than one that changes something. Te<HealthCheckFlow />-### Setting a check-<Steps><Step title="Open the sync's Commands step">Edit the sync and select **Commands**.</Step><Step title="Write the check">- The script runs with `$ErrorActionPreference` set to `Stop`, so a failing cmdlet is enough to mark the host not ready. Use `throw "reason"` when you want to say why:+ Use `throw "reason"` when you want to say why the host is not ready:```powershellif (-not (Test-Path {{certificateDirectory}})) { throw "destination folder is missing" }if ((Get-Service W3SVC).Status -ne "Running") { throw "W3SVC is not running" }```- </Step>- <Step title="Save and trigger a sync">- Save the sync, then trigger it. If the check fails, the sync fails without delivering, and the reason appears as the sync's last error.- </Step>-</Steps>--### Available variables--<HealthCheckVariables />--### Length limit--A check is limited to 8192 characters, counted as you write it, before variables are substituted. For anything longer, put the logic in a script file on the server and have the check call that script.--Going past 2048 characters requires a Gateway on Infisical CLI v0.43.124 or later. See the Gateway version note above.-### Health check FAQ+ To check every certificate the run would write instead of one, split `{{certificateFiles}}` on newlines and loop over it:-<AccordionGroup>- <Accordion title="When exactly does the check run?">- Before anything else in a sync run, in its own WinRM session, before the one Infisical would deliver with. It also runs once a day on its own, whether or not a sync is due.- </Accordion>- <Accordion title="What happens when the check fails?">- The sync is marked failed and the reason appears as the sync's last error. Every certificate in the run is reported as skipped with that same reason, so it is clear nothing reached the host. Files already on the server from an earlier run are left exactly as they are, because the sync never wrote or deleted anything.- </Accordion>- <Accordion title="How do I make the check fail deliberately?">- Use `throw "reason"`, the same as in a post-sync command. Avoid `exit`: PowerShell stops the script there before it can report its result, so the check is treated as failed with a message saying the outcome could not be read rather than with your reason.- </Accordion>- <Accordion title="Where do I see the result of the daily check?">- A failing daily check records the failure and its reason against the sync's health check, shown as Last Checked on the sync's page, and notifies the application's administrators. It does not change the sync's own status, which continues to report the last delivery. Either way the run is recorded in the sync's logs with the command and the first part of its output.- </Accordion>- <Accordion title="Is there a time limit?">- Yes, 15 seconds, and a check that runs out of time counts as a failure. The limit is deliberately much shorter than the post-sync command's, because the check gates delivery: a host that cannot answer a readiness question in fifteen seconds is itself the problem worth reporting. Keep the check to a question that is cheap to answer.+ ```powershell+ {{certificateFiles}} -split "`n" | ForEach-Object { if (-not (Test-Path (Split-Path $_ -Parent))) { throw "missing folder for $_" } }+ ```+ </Step>+ <Step title="Test it, then save the sync">+ **Test check** runs the check against the host straight away, so you can see the result without waiting for a sync. It resolves variables against the certificates linked to the sync, so it works once at least one is selected and tells you if none is. `{{pkcs12Password}}` is the exception: the export password only exists once a saved sync delivers a certificate, so a test always rejects it.- On Windows the fifteen seconds bound how long Infisical waits, not the host. WinRM gives no way to cancel a command once it has started, so a check that hangs is reported as a timeout and the sync fails, but the command itself keeps running on the server until it finishes. This is the other reason to keep a check to a cheap question rather than real work.- </Accordion>- <Accordion title="Does a failed check get retried?">- Not within the run. A host that is not ready is usually not ready a few seconds later either, so retrying only delays the report. The next sync or the next daily check is the retry.- </Accordion>- <Accordion title="Can I use it to prepare the host instead of just checking it?">- You can, since it is a free-text command, but prefer not to. A check that also does work runs before every sync and has fifteen seconds to finish, and if it fails halfway you have changed the host and delivered nothing. Keep preparation in the post-sync command, or in a script the check only verifies the result of.- </Accordion>-</AccordionGroup>+ Save the sync once the check passes. On a real run, a failing check fails the sync without delivering anything, and the reason appears as the sync's last error.+ </Step>+</Steps>-## Post-sync commands+### Post-sync commandDelivering a `.pfx` to `C:\certs` does not make IIS or a service use it. A post-sync command is that last step, run for you right after the files land.-Set one command on the sync. The Gateway runs it as PowerShell on the target server, once per sync run that delivers at least one file. Leaving the field empty means nothing runs, so there is no separate toggle. If a sync run does not complete, Infisical may attempt it again and the command runs with it, so prefer a command that is safe to run more than once.--The field accepts a whole script, so several steps can run in one go: put each on its own line.--Your Gateway runs the command, never Infisical. A WinRM Connection already requires a gateway, so nothing extra is needed here.--<Note>- The Gateway must be running Infisical CLI **v0.43.120 or later**. An earlier Gateway has no PowerShell run-command endpoint and rejects the request. A command longer than 2048 characters needs **v0.43.124 or later**, because earlier Gateways cap it at 2048 and reject the sync even though the form accepted the command. Run `infisical --version` on the Gateway host to check, and see [Gateway deployment](/documentation/platform/gateways/gateway-deployment) for how to upgrade.-</Note>+It runs once per sync run that delivers at least one file. If a sync run does not complete, Infisical may attempt it again and the command runs with it, so prefer a command that is safe to run more than once.<PostSyncCommandFlow />-### Setting a command-<Steps><Step title="Open the sync's Commands step">Edit the sync and select **Commands**.@@ -226,29 +216,24 @@ Your Gateway runs the command, never Infisical. A WinRM Connection already requi</Step></Steps>-### Available variables--<PostSyncCommandVariables />--### Length limit--A command is limited to 8192 characters, counted as you write it, before variables are substituted. For anything longer, put the logic in a script on the server and call that script.--Going past 2048 characters requires a Gateway on Infisical CLI v0.43.124 or later. See the Gateway version note above.--### Post-sync command FAQ+### Command FAQ<AccordionGroup>- <Accordion title="When exactly does the command run?">- After every file in the run has been delivered and after any removals, so the server is in its final state before the service restarts. A run that delivers nothing runs nothing. Renewals, adding a certificate, and a manual trigger all deliver files, so all three run the command. Removing a certificate from the sync does not.+ <Accordion title="When exactly does each command run?">+ The health check runs before anything else in a sync run, in its own WinRM session, before the one Infisical would deliver with. It also runs once a day on its own, whether or not a sync is due.++ The post-sync command runs after every file in the run has been delivered and after any removals, so the server is in its final state before the service restarts. A run that delivers nothing runs nothing. Renewals, adding a certificate, and a manual trigger all deliver files, so all three run the command. Removing a certificate from the sync does not.</Accordion>- <Accordion title="What happens if the command fails?">- The sync is marked failed and the reason appears as the sync's last error. The delivered files stay in place, because they were written before the command ran. A silent failure is reported as a failure: the script stops on the first error, and a native command's own non-zero exit code is passed through. A command that fails is reported, not repeated.+ <Accordion title="What happens when a command fails?">+ Either way the sync is marked failed and the reason appears as the sync's last error. A silent failure is reported as a failure: the script stops on the first error, and a native command's own non-zero exit code is passed through. A command that fails is reported, not repeated.- To fail the sync deliberately, use `throw "reason"`. Avoid `exit`: PowerShell stops the script there before it can report its result, so the sync is failed with a message saying the outcome could not be read rather than with your reason.+ What is left on the host differs. When the **health check** fails, every certificate in the run is reported as skipped with that same reason, so it is clear nothing reached the host, and files already on the server from an earlier run are left exactly as they are, because the sync never wrote or deleted anything. When the **post-sync command** fails, the delivered files stay in place, because they were written before the command ran.+ </Accordion>+ <Accordion title="How do I fail a command deliberately?">+ Use `throw "reason"`, in either field. Avoid `exit`: PowerShell stops the script there before it can report its result, so the command is failed with a message saying the outcome could not be read rather than with your reason.</Accordion><Accordion title="Can I run several commands, and what happens if one of them fails?">- Yes, write one per line.+ Yes, in either field. Write one per line.A failing **cmdlet** (`Copy-Item`, `Restart-Service`, and so on) stops the script and fails the sync wherever it appears, because the script runs with `$ErrorActionPreference` set to `Stop`. A failing **external executable** is different: only the last statement decides the outcome, so an earlier `.exe` that fails is not noticed. That is deliberate, because a non-zero exit is routine for some tools (`findstr` returns 1 when nothing matched, `robocopy` returns 1 when it copied files) and those should not fail a sync. Check the ones you care about yourself:@@ -258,21 +243,26 @@ Going past 2048 characters requires a Gateway on Infisical CLI v0.43.124 or lateRestart-Service -Name W3SVC```</Accordion>- <Accordion title="Can the command run twice for the same certificate?">- Yes, in some cases. If a sync run does not complete, Infisical may attempt it again, and the command runs as part of that attempt. Prefer a command that is safe to run more than once. A service restart is.- </Accordion><Accordion title="Is there a time limit?">- Yes, 30 seconds, enforced by the Gateway. A command that needs longer should start the work in the background or live in a script on the server.- </Accordion>-</AccordionGroup>--### Least privilege+ Yes, and it differs by command: 15 seconds for the health check, 30 seconds for the post-sync command. Both are enforced by the Gateway, and running out of time counts as a failure.-Both the health check and the post-sync command run as the account the WinRM Connection authenticates with, so constraining that account bounds what either can do. Restarting one service does not need an administrator. Grant the connection account start and stop rights on that single service instead of making it a local administrator.+ The check's limit is deliberately much shorter, because the check gates delivery: a host that cannot answer a readiness question in fifteen seconds is itself the problem worth reporting. Keep the check to a question that is cheap to answer, and give a post-sync command that needs longer than thirty seconds a script on the server that starts the work in the background.-Binding a certificate to an HTTPS port in IIS is the exception: HTTP.sys requires a local administrator and the right cannot be delegated. Because a local administrator can do anything on the host, handle that case with a dedicated, clearly labeled sync rather than raising the privileges of a sync that only needs to deliver files and restart a service. Infisical does not block an administrator credential on a standard sync, so this is a recommendation you enforce with how you configure the connection.--Anyone who can edit the sync can change either command, so treat edit access to these syncs as access to the target server. Setting them is a separate permission from editing the sync, so a role can be allowed to change a sync's destination and options without being allowed to change what it runs on the host.+ On Windows the limit bounds how long Infisical waits, not the host. WinRM gives no way to cancel a command once it has started, so a command that hangs is reported as a timeout and the sync fails, but the command itself keeps running on the server until it finishes. This is the other reason to keep a check to a cheap question rather than real work.+ </Accordion>+ <Accordion title="Can a command run twice for the same certificate?">+ Yes, in some cases. If a sync run does not complete, Infisical may attempt it again, and both commands run as part of that attempt. Prefer commands that are safe to run more than once. A service restart is.+ </Accordion>+ <Accordion title="Does a failed health check get retried?">+ Not within the run. A host that is not ready is usually not ready a few seconds later either, so retrying only delays the report. The next sync or the next daily check is the retry.+ </Accordion>+ <Accordion title="Where do I see the result of the daily health check?">+ A failing daily check records the failure and its reason against the sync's health check, shown as Last Checked on the sync's page, and notifies the application's administrators. It does not change the sync's own status, which continues to report the last delivery. Either way the run is recorded in the sync's logs with the command and the first part of its output.+ </Accordion>+ <Accordion title="Can I use the health check to prepare the host instead of just checking it?">+ You can, since it is a free-text command, but prefer not to. A check that also does work runs before every sync and has fifteen seconds to finish, and if it fails halfway you have changed the host and delivered nothing. Keep preparation in the post-sync command, or in a script the check only verifies the result of.+ </Accordion>+</AccordionGroup>## Securitydiff --git a/docs/snippets/documentation/platform/pki/applications/certificate-syncs/post-sync-command-variables.mdx b/docs/snippets/documentation/platform/pki/applications/certificate-syncs/command-variables.mdxsimilarity index 67%rename from docs/snippets/documentation/platform/pki/applications/certificate-syncs/post-sync-command-variables.mdxrename to docs/snippets/documentation/platform/pki/applications/certificate-syncs/command-variables.mdxindex 5aba170711..45a126ec78 100644--- a/docs/snippets/documentation/platform/pki/applications/certificate-syncs/post-sync-command-variables.mdx+++ b/docs/snippets/documentation/platform/pki/applications/certificate-syncs/command-variables.mdx@@ -1,21 +1,19 @@-Write a variable where you want this run's value. Infisical replaces it before the command is sent to the server, so the command keeps working when the name schema or export format changes.+Write a variable where you want this run's value. Infisical substitutes it before the command is sent to the server, so a command keeps working when the name schema or export format changes.| Variable | Value || --- | --- |-| `{{certificatePath}}` | Full path of the certificate file delivered this run. Single-certificate syncs only |+| `{{certificatePath}}` | Full path of the certificate file this run writes. Single-certificate syncs only || `{{certificateDirectory}}` | The destination directory |-| `{{certificateFiles}}` | Every path written this run, one per line |+| `{{certificateFiles}}` | Every path this run writes, one per line || `{{commonName}}` | The certificate's common name. Single-certificate syncs only || `{{pkcs12Password}}` | The PKCS#12 export password, set only when the export format is PKCS#12 |+The paths are the same for both commands, but a health check runs before anything is written, so they describe the files the run is *about to* write rather than files already on the host.+Each value is inserted already quoted for the target's shell, so write `{{certificatePath}}` rather than `"{{certificatePath}}"`. A variable that has no value for the run becomes an empty string.Only the names in this table are substituted. Anything else in double braces is left in the command exactly as you wrote it, so a command that calls a tool with its own braces (helm, jq, a Go template) keeps working, and a misspelled variable reaches the server as literal text rather than silently turning into nothing.<Note>- `{{certificatePath}}` and `{{commonName}}` name one specific certificate, so a command that uses either can only be saved on a sync with a single certificate linked. Linking a second certificate to such a sync is rejected, as is adding one of these variables to a sync that already has several. To act on every certificate in the run, use `{{certificateFiles}}`, which lists one path per line:-- ```bash- echo {{certificateFiles}} | while read -r file; do echo "delivered $file"; done- ```+ `{{certificatePath}}` and `{{commonName}}` name one specific certificate, so a command that uses either can only be saved on a sync with a single certificate linked. Linking a second certificate to such a sync is rejected, as is adding one of these variables to a sync that already has several. To act on every certificate in the run, use `{{certificateFiles}}`, which lists one path per line.</Note>diff --git a/docs/snippets/documentation/platform/pki/applications/certificate-syncs/health-check-variables.mdx b/docs/snippets/documentation/platform/pki/applications/certificate-syncs/health-check-variables.mdxdeleted file mode 100644index 8890aec3ab..0000000000--- a/docs/snippets/documentation/platform/pki/applications/certificate-syncs/health-check-variables.mdx+++ /dev/null@@ -1,23 +0,0 @@-Write a variable where you want this run's value. The check runs before anything is written, so the paths describe the files the run is *about to* write rather than files already on the host.--| Variable | Value |-| --- | --- |-| `{{certificatePath}}` | Full path of the certificate file this run will write. Single-certificate syncs only |-| `{{certificateDirectory}}` | The destination directory |-| `{{certificateFiles}}` | Every path this run will write, one per line |-| `{{commonName}}` | The certificate's common name. Single-certificate syncs only |-| `{{pkcs12Password}}` | The PKCS#12 export password, set only when the export format is PKCS#12 |--Each value is inserted already quoted for the target's shell, so write `{{certificatePath}}` rather than `"{{certificatePath}}"`. A variable that has no value for the run becomes an empty string.--Only the names in this table are substituted. Anything else in double braces is left in the command exactly as you wrote it, so a command that calls a tool with its own braces (helm, jq, a Go template) keeps working, and a misspelled variable reaches the server as literal text rather than silently turning into nothing.--A variable that names a certificate resolves against the certificates linked to the sync, so **Test check** works once at least one is selected and tells you if none is. `{{pkcs12Password}}` is different: the export password only exists once a saved sync delivers a certificate, so a test always rejects it.--<Note>- `{{certificatePath}}` and `{{commonName}}` name one specific certificate, so a check that uses either can only be saved on a sync with a single certificate linked, exactly as for the [post-sync command](#post-sync-commands). To act on every certificate the run would write, use `{{certificateFiles}}`:-- ```bash- echo {{certificateFiles}} | while read -r file; do test -w "$(dirname "$file")"; done- ```-</Note>