Skip to main content
The certgov-agent automates certificate renewal on network devices by running script templates — shell scripts or PowerShell commands — that interact with each device’s management API or CLI. If you can write a script to pull a CSR and install a cert, any device is supported.
No inbound firewall rules are required. The agent polls CertGov for pending renewal jobs, runs the configured template scripts against the device, and reports results back.

Prerequisites

  • certgov-agent installed and enrolled — see CertGov Agent
  • TCP access from the agent host to the device management IP on its configured port (typically 443)
  • The agent host running a shell interpreter for your scripts (bash, PowerShell, Python)

How device automation works

1 — Register the device as a Managed Host

In CertGov: Integrations → Managed Hosts → + Add Host Enter the device’s name, management IP, port, and connection credentials. Credentials are stored AES-256-GCM encrypted in CertGov and delivered to the agent at job execution time — never stored on the agent host. Assign a Device Template that defines the scripts used to interact with this device type.

2 — Device Templates

A Device Template is a set of script steps executed by the agent when renewing a cert: Templates receive device details (IP, port, credentials) and certificate data as environment variables — no hardcoded values, no secrets in template code. CertGov ships built-in templates for common devices, and you can create custom templates for any device in your environment.

3 — Renewal cycle

When a cert on a Managed Host approaches its renewal window:
  1. CertGov queues a renewal job for the assigned agent
  2. Agent polls and picks up the job (within poll_interval, default 30s)
  3. Agent runs the get_csr script — retrieves or generates a CSR on the device
  4. CSR is submitted to CertGov; signed under the Domain Trust Profile
  5. Agent runs install_cert script — pushes the signed cert to the device
  6. Agent optionally runs verify script — confirms deployment
  7. Job marked complete; next renewal window scheduled
  8. All steps appear in the CertGov audit log

Built-in device templates

CertGov includes templates for common network and telephony devices:
AudioCodes Mediant on firmware 7.60A or later with the ACME license can request certificates directly from CertGov via the ACME protocol — no agent required. See ACME Setup if your device supports it. The mediant-v7 template is the right choice for devices without the ACME license.

direct_rest_api driver

Some templates — including AudioCodes Mediant — use the direct_rest_api driver. In this mode CertGov itself makes the REST calls directly to the device; no agent binary is required on a separate host. The API host (Managed Host) must have:
  • Driver: direct_rest_api
  • Auth type: basic_auth (for Mediant and most network appliances)
  • Base URL: https://<device-ip>/
Scripts for this driver use a simple HTTP-style format — method and path on the first line, optional header declarations next, then the body:
Lines between the method line and the body that match Key: value format are sent as HTTP request headers. Any unrecognised header simply passes through to the device.

Variable substitution

All scripts (both agent and direct_rest_api) support {{VAR}} substitution anywhere — including the URL path: Set arbitrary variables in Managed Hosts → Edit → Extra Vars and reference them from any script. This is the recommended pattern for device-specific parameters (slot numbers, interface IDs, TLS context index, etc.).

Multi-context and multi-cert devices

Devices that hold multiple certificates — for example an AudioCodes Mediant with separate TLS contexts for SIP, HTTPS management, and Teams Direct Routing — should be registered as separate Managed Hosts, one per certificate slot: Each host has its own cert lifecycle, verify address, and delivery history. The same mediant-v7 template serves all of them.

Add any device — no Go coding required

This is the key difference from earlier connector architectures. Device support is defined by scripts, not compiled Go code. Adding a new device type means writing the get_csr and install_cert scripts for that device’s API or CLI, or a direct_rest_api script for devices with a REST API. Any device with a REST API, SSH interface, or command-line tool is supported. Example: custom device via REST API
Scripts receive standard environment variables from the agent: Create a custom template in Integrations → Device Templates → + New Template and assign it to a Managed Host. This means:
  • Any scriptable device is supported — not just the built-in list
  • Your team controls the timeline — no vendor ticket, no CertGov update required
  • Templates are version-controlled in CertGov — auditable and managed through the UI
  • Script templates can be shared — export and import between CertGov environments

Background cert discovery

On startup and every 6 hours, the agent TLS-dials each registered Managed Host and reads the current leaf certificate — no device credentials needed. It reports the cert’s expiry date, Common Name, and SANs back to CertGov. From the Managed Hosts page, clicking Query Cert triggers an immediate on-demand read.

On-prem CA signing (optional)

By default, CSRs are sent to CertGov for signing against your configured CA. If your signing CA is on-premises, assign a CA connector to the agent in Integrations → CA Connectors → Edit. The agent then signs locally, with CertGov authorizing each request against your Domain Trust Profile before the CA key is used. If CertGov is unreachable, the agent will not sign — it is fail-closed. All signed certs are reported back to CertGov for inventory and audit.

Monitoring

In CertGov under Integrations → Connector Agents, each agent shows version, last seen timestamp, poll interval, number of CA connectors assigned, and number of Managed Hosts connected. The Managed Hosts page shows the current cert on each device, expiry date, and last renewal status.

Security

Device credentials are stored encrypted in CertGov and delivered to the agent only when a job runs — never persisted to disk on the agent host. Script execution runs as the agent service user (the certgov system account when running as a Linux systemd service). Scope agent permissions to only what the scripts need. Firewall requirements — the agent requires outbound HTTPS only:

Deploying the agent in Azure (VNet)

To reach devices on a private Azure VNet, run certgov-agent on a VM inside that VNet (see CertGov Agent for the Linux and Windows install).

Script audit trail

Every edit to a script in Integrations → Scripts is logged. Open any script and scroll to the Change History section to see a before/after diff of every previous version, who made the change, and when. Platform-default scripts (the built-in templates that ship with CertGov) are never overwritten by application updates. If you have customised a built-in script, your version is preserved across upgrades. Use the Scripts UI to intentionally update or revert to the default.

Troubleshooting

Agent connects but devices show no cert data
  • Verify TCP access from the agent host to the device management IP and port
  • Check the device is set to Active on the Managed Hosts page
  • Run the agent manually to see log output: certgov-agent run --config /etc/certgov-agent/agent.yaml
Script step failed
  • Check the job’s Phase Log in the CertGov UI — the error is captured with an actionable hint (connection refused, auth failure, wrong address, etc.) followed by the raw error
  • For direct_rest_api failures: verify the host’s Auth Type is set correctly (basic_auth for AudioCodes Mediant; session_cookie for Ribbon)
  • For address errors: the Verify Address field should be host:port format — schemes (https://) are stripped automatically, and :443 is appended if no port is given
  • Check the Dispatched Scripts panel on the job to see the exact script that ran with all variables substituted; any unresolved {{VAR}} placeholders (without a default) appear verbatim and indicate a missing extra_var on the host
Jobs created but never picked up
  • Confirm the agent is showing as online in Integrations → Connector Agents
  • Check journalctl -u certgov-agent for errors
  • Verify the Managed Host is assigned to this agent