Skip to main content
Looking for a step-by-step setup guide? See Automate certificates with Infisical Agent.
The Infisical Agent is a client daemon packaged into the Infisical CLI. In certificate management mode, it requests a certificate from an Application using the API enrollment method, persists it to the filesystem, and monitors and renews it before expiration. This follows the client-driven approach to certificate renewal, where key material stays under the client’s control. The agent authenticates with Infisical as a machine identity, using infrastructure-native authentication methods where available so no long-lived credentials need to be distributed. It also supports post-event hooks to run custom commands after certificate issuance, renewal, or failure events, such as reloading a web server.

Running the agent

Start the agent with the --config flag pointing to your configuration file:
This starts the agent as a daemon process that continuously monitors and manages certificates according to your configuration. Add --verbose to enable debug logging when troubleshooting. Instead of a file, you can pass the entire configuration through the INFISICAL_AGENT_CONFIG_BASE64 environment variable as a base64-encoded string. This is useful in containerized environments where mounting files is inconvenient. For production deployments, run the agent as a system service so it starts automatically and runs continuously.

Configuration file

The agent is driven by a YAML configuration file with four top-level sections: version, infisical, auth, and certificates.
agent-config.yaml
Set version to v2. Each certificate entry references an Application and a certificate profile attached to it by name, or an existing certificate by ID (see Tracking an existing certificate).

Duration format

Duration values (ttl, renew-before-expiry, status-check-interval, failure-retry-interval) accept standard time units (30s, 10m, 6h) plus a day suffix (14d, 90d).

Infisical connection

Authentication

The auth section configures how the agent authenticates with Infisical as a machine identity. Upon successful authentication, the agent receives a short-lived access token that it automatically renews for the lifetime of the process. Set auth.type to one of the supported methods and provide the matching fields under auth.config:
Credential fields (client-id, client-secret, identity-id, username, password) take a path to a file containing the value, not the value itself. This keeps credentials out of the configuration file. Alternatively, supply the value through the matching environment variable, which takes precedence over the file.
service-account-token (Kubernetes) and service-account-key (GCP IAM) are file paths handed to the authentication flow directly; their environment variables override the path, not the content.

Certificate parameters

Each entry in the certificates list accepts the following parameters:

Post-event hooks

The agent runs custom commands in response to certificate lifecycle events through the post-hooks configuration. Commands run through the system shell, so they can chain multiple actions.
Runs when a new certificate is successfully issued:

Example configurations

One-time certificate issuance

Requests a certificate once without any subsequent auto-renewal (no lifecycle section):

One-time issuance from a pre-generated CSR

Submits a pre-generated CSR to Infisical for signing. When csr-path is specified:
  • The private-key output is omitted because the key pair is generated and managed externally; only the CSR is submitted to Infisical for signing.
  • The agent cannot auto-renew the certificate, since it does not hold the private key required to generate a new CSR.

Issuance with automatic renewal

Requests a certificate and continuously renews it 14 days before expiration, checking the certificate status every 6 hours:

Tracking an existing certificate

Instead of issuing a new certificate, the agent can fetch an existing one by setting certificate-id. The agent downloads the certificate bundle, writes it to the configured paths, and monitors its status on the configured status-check-interval. If the certificate is revoked or expires, the agent runs the on-failure hook and stops. Use this when the certificate’s lifecycle is managed in Infisical (for example, through server-driven auto-renewal) and the agent’s job is only to deliver it to the machine. This is also how several machines share one certificate. Ten web servers terminating TLS for *.example.com can point at the same certificate-id and serve the same wildcard certificate, instead of each issuing its own. Nothing reaches the certificate authority, and your inventory does not grow with the fleet. certificate-id replaces the fields that describe a new certificate. Combining it with application-name, profile-name, attributes, csr or csr-path is rejected when the agent starts, rather than silently ignored.
The machine identity the agent authenticates as needs permission to read the certificate you point it at. Without it, the agent reports the authorization failure and leaves any files it has already written untouched.

Following renewals

Renewing a certificate produces a new certificate with its own ID, and the one it replaced stays valid until its own expiry. An agent pinned to the original ID therefore keeps serving the original. Set lifecycle.replace-on-renewals to true and the agent delivers the most recent renewal instead:
Renewing the certificate once in Infisical then reaches every machine running the agent, with no configuration change and no manual step on the machines. Leave certificate-id pointing at the certificate you started from: Infisical resolves the most recent renewal for you, however many times it has been renewed. The agent rewrites the files only when the certificate it resolves to changes, and runs the on-renewal hook when that happens. When nothing has changed it writes nothing and runs no hooks, including across a restart, because it compares what it resolves against the certificate already on disk.
lifecycle.renew-before-expiry has no effect alongside certificate-id. The agent delivers a certificate, it does not renew one. The agent logs a warning and carries on. Use lifecycle.replace-on-renewals instead.
What to expect in less common cases:
  • A revoked or expired certificate is reported and runs the on-failure hook, but the agent does not overwrite what is already on disk. The machine keeps serving the last certificate known to be good.
  • A certificate that Infisical does not hold a private key for, such as one issued from a certificate signing request or through ACME, is written along with its chain. The agent logs a warning and skips the private key file. If such a certificate would replace one already delivered, the agent refuses the write instead, because that would leave a non-matching certificate and key on disk.
  • status-check-interval sets how often the agent checks, and so how quickly a renewal reaches the machine.
  • Keep the certificate named in certificate-id, even after it has been renewed. The agent starts from it. Certificates that replaced it can be deleted safely.
  • replace-on-renewals requires an Infisical server that supports it. Against an older self-hosted instance the agent cannot tell that a renewal exists, so it logs a warning and stays on the certificate it already delivered.