Skip to main content

Overview

With key custody, CertGov writes each new certificate’s private key to your HashiCorp Vault or OpenBao (KV version 2) at issuance and deletes its own copy. When a certificate is delivered, the connector agent on your network reads the key from your vault itself. CertGov never holds a login that can read your keys.
Key custody is set per trust profile. On Trust Profiles, the Keys column shows where each profile’s keys live: CertGov (encrypted), or your key store’s name.
Using Azure Key Vault instead? See Azure Key Vault, Path B. Delivering certificates whose key is in Azure Key Vault isn’t supported yet.

Requirements

  • HashiCorp Vault or OpenBao with a KV version 2 secrets engine (the examples use the default secret/ mount)
  • A connector agent, v0.1.11 or later, on a host that can reach your vault and your servers
  • Your vault reachable from the agent. In Agent access mode (recommended), CertGov never connects to your vault directly

1. Create the vault policies

CertGov writes keys under <mount>/<path prefix>/<certificate ID>, by default secret/certgov/keys/<id>. Write-only policy, for CertGov:
Read-only policy, for your agent:
The write policy lets CertGov store keys without being able to read them. If you use a different mount or path prefix, change the paths to match.

2. Add the key store host

In CertGov, go to Hosts → Add Host and set: Create the token:

3. Turn on key custody in the trust profile

Edit the trust profile, and under Advanced → Key Custody choose the host as the Key Store Host. From then on, every certificate issued under the profile has its key written to your vault, and CertGov deletes its copy. Certificates issued before you turned it on keep their keys in CertGov. To stop, set Key Store Host back to none; new certificates then keep their keys in CertGov again.

4. Give the agent its read token

On the agent’s host, create a read-only token and store it in a file only the agent’s service user can read (certgov if you followed the agent guide; use root if the agent runs as root):
Add a vault section to /etc/certgov-agent/agent.yaml:
Then restart the agent:
The agent can also take the token from the VAULT_TOKEN environment variable instead of token_file.

5. Deliver

Use Deliver or Test on the service’s targets as usual. For a certificate whose key is in your vault, CertGov sends the agent the certificate and the key’s location, not the key. The agent reads the key, then runs the delivery template with it, exactly as if CertGov had sent the key. Templates need no changes. The agent that runs the job does the read, including for SSH targets: it reads the key, then installs it on the target over SSH. The read token only needs to be on the agent’s host, not on every server.

Keeping the agent’s token valid

The read token belongs to you: you create it, choose its policy, and can revoke it at any time. A periodic token (-period=768h) stays valid as long as it’s renewed at least once per period.
  • Renew it on a schedule, for example a daily vault token renew using the token file, or
  • Let Vault Agent manage it: point Vault Agent’s token sink at /etc/certgov-agent/vault-token. The connector agent rereads the file for every delivery, so a rotated token is picked up without a restart.
If the token expires, deliveries of vault-held keys fail with a 403 from your vault until you replace the file.

Troubleshooting

Security notes

  • CertGov stores the key store’s write token. With the write-only policy above, that token can’t read keys back.
  • At issuance the key is saved in CertGov encrypted (AES-256-GCM) until the write to your vault succeeds, then deleted. If the write fails, CertGov keeps the encrypted key and the certificate works as one without key custody.
  • Downloading the private key from Inventory isn’t available for these certificates. Read it from your vault instead.