7. Keystore

Keep your private keys on your own infrastructure.

Plan Requirement: The CertKit Keystore is a premium local security and compliance service and is only available on our Enterprise tier plans.

The CertKit Keystore is a service you run on your own server that generates and stores private keys inside your infrastructure. For collections that use it, the keystore generates every new private key, and CertKit’s cloud services only handle the public material (CSRs and issued certificates). Those keys never leave the keystore host, except to your own agents when they deploy a certificate.

Source code is available at github.com/certkit-io/certkit-keystore.

This page describes keystore v2. If you run v1, see Upgrading from v1.

Purpose

The Keystore is for environments where compliance or security requirements say private keys must stay on local infrastructure.

One Keystore per Account

An account has one keystore, and it can serve any number of certificate collections. Collections opt in one at a time, so you can keep some collections on the keystore and leave others with CertKit.

To switch a collection, an account administrator opens that collection’s Keystore page and chooses Use the Keystore for This Collection. From then on:

  • New private keys are generated on the keystore. From each certificate’s next renewal, CertKit only sees the public CSR.
  • Existing certificates and keys move to the keystore, and agents fetch them from the keystore instead of CertKit. CertKit generated those keys, and each one is replaced by a keystore-generated key at the certificate’s next renewal. If CertKit must never hold a key, switch the collection to the keystore before you add certificates to it.
  • CertKit stops handing out private keys for the collection. Key downloads, download links, and the S3 copies are turned off.

Switching a collection to the keystore can’t be undone. Once the keystore generates a certificate’s private key, CertKit never has it, so the collection can’t move back.

Every agent in the collection must run CertKit Agent 1.7.0 or newer before the collection can switch.

Encryption at Rest

Every certificate and CA private key the keystore stores is encrypted on disk with AES-256-GCM. The encryption key is held by CertKit, not by the keystore host. The keystore asks CertKit for it at startup, using the identity in its config file, and keeps it in memory only. It is never written to the keystore’s disk.

This splits what is needed to read a key between two places:

  • Your server holds the encrypted key files.
  • CertKit holds the encryption key. For keys the keystore generated, CertKit never has the files.

Someone who copies the storage directory, or finds an old backup of it, gets ciphertext. The files can only be read by the keystore that is registered to your CertKit account.

Two things follow from this design:

  • The keystore needs CertKit to start. If the keystore restarts while it can’t reach CertKit, it waits and retries until it gets its encryption key, and it doesn’t serve certificates until then.
  • Protect the config file. config.json holds the identity the keystore uses to fetch its encryption key, and by default it sits in the folder above the storage directory. Anyone with both config.json and the storage directory has what the keystore has, and that includes a full disk image or a backup of the whole server. If you think the config file has been exposed, contact hello@certkit.io.

Private CA Keys

A Private PKI certificate authority can keep its keys on the keystore. Choose On your keystore under Private Keys when you create the CA. The keystore generates the CA keys and signs every certificate and CRL the CA issues. CertKit holds only the CA’s certificates.

Because the keystore does the signing, it has to stay online. CRLs last 7 days and the keystore renews them daily. These keys exist nowhere else: if the keystore and its backups are lost, the CA can never sign again.

Leaf certificates from any private CA are handled like public ones. In a collection that uses the keystore, their keys are generated on the keystore and signed from a CSR.

Trade-offs

Using a local Keystore introduces several management requirements:

  • Backups: You are responsible for backing up the keystore. Lost keys cannot be recovered by CertKit. See Backups.
  • Availability: If the keystore is offline when a certificate is due to renew, that certificate waits until the keystore is back.
  • Restricted Access: Manual downloads of PFX and Private Key files are disabled via the dashboard to ensure keys remain on-premise.
  • Enterprise-Only: The Keystore is only available with Enterprise CertKit plans.

Installation

Installation requires a server or VM to host the keystore, the hostname or IP and port that agents will use to reach it, and a folder for certificate storage. The install commands and your registration key are on the Settings > Keystore page. Linux installs as a systemd service. Windows installs as a Windows Service from a signed MSI, which also runs as a setup wizard or silently with msiexec.

After the keystore registers, an account administrator checks its details on Settings > Keystore and authorizes it.

Network Requirements

Agents retrieve certificate material from the keystore over HTTPS. The keystore listens on port 443 by default. You can set a different port during installation.

If a firewall sits between an agent and the keystore host, allow inbound TCP traffic to the keystore on port 443 (or the port you configured). Every agent that retrieves certificate material needs this access, including agents on networks outside your data center. Connections use TLS 1.3 with a server certificate the keystore manages automatically.

The keystore host also needs outbound HTTPS access to CertKit to fetch its encryption key, send CSRs, receive issued certificates, and validate agent requests.

Keystore Settings

The Settings > Keystore page for a running keystore, showing its URL, version, encryption at rest turned on, and host details
Settings > Keystore for a running keystore.

Settings > Keystore shows the keystore’s status and host details, whether encryption at rest is on, the collections that use the keystore with how many of their certificates are stored, and the private CAs that keep their keys on it.

Each collection that uses the keystore also has a Keystore page with a per-certificate status table. Watch it for error states, which mean a key or certificate wasn’t stored correctly.

Status Page and Logs

The keystore serves its own status page at the Keystore URL. Open it from View Keystore Status Page on the settings page, from a machine that can reach the keystore. It asks you to log in through CertKit, and only administrators of the account that owns the keystore get in.

The status page lists every stored certificate by collection with its expiration and whether its key is encrypted, the private CA keys the keystore holds, the last check-in with CertKit, and the keystore’s own TLS certificate. Your browser will warn about the page’s certificate, because it is issued by the keystore’s own CA, which only your agents are told to trust.

Show logs on the status page shows the keystore’s log, newest entries first, and downloads it. A keystore running in a container writes its log to the container’s output instead.

Updates

When a new keystore release is available, Settings > Keystore shows an Update Now button. The keystore downloads the release on its next check-in, verifies its checksum, and restarts on the new version. On Windows the new version must also be signed by the same publisher as the running one. Keystores running in containers don’t update themselves.

Upgrading from v1

Keystore v1 serves a single collection, stores keys unencrypted, can’t hold private CA keys, and can’t update itself. To upgrade, re-run the install command from Settings > Keystore on the keystore server. Your configuration and stored certificates are kept, and nothing has to be entered again. On first start, v2 encrypts the stored private keys. Certificates move into per-collection folders the first time the keystore checks in with CertKit.

Backups

Back up config.json and the storage directory together, and store the backup as carefully as the keystore itself. The storage directory can’t be read without the registration in config.json. If you restore a storage directory under a different registration, the keystore can’t read it, moves it aside, and starts over.

This matters most for private CAs that keep their keys on the keystore, because those keys exist nowhere else.

For how CertKit protects keys it holds, and how the Keystore fits into the overall security model, see Security.