Secret backends
Store sensitive configuration values — database passwords, API keys, tokens — in an external secret manager instead of plain text in the KMS TOML config file.
How it works
- In your
kms.toml(or, for the clients,ckms.toml— see Client configuration), replace any sensitive value with asecret://...URI. - Start the KMS with
--backend <backend>(or setKMS_SECRET_BACKENDenv var). - At startup the KMS resolves every
secret://URI once, then applies the config normally.
The config file never contains actual secrets — only references.
Supported backends
| Backend | --backend | URI format | Required env vars |
|---|---|---|---|
| HashiCorp Vault | vault | secret://<mount>/<path>[#<field>] | VAULT_ADDR, VAULT_TOKEN |
| AWS SSM Parameter Store | aws-ssm | secret://<region>/<parameter-name> | AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY |
| Azure Key Vault | azure-kv | secret://<vault>/secrets/<name>[/<version>] | AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET |
| Eviden KMS | cosmian-kms | secret://<host>[:<port>]/<object-id> | (optional) COSMIAN_KMS_SECRET_TOKEN |
HashiCorp Vault
Uses the KV-v2 secrets engine. The URI fragment #field selects a specific
key in the secret's JSON data; defaults to value if omitted.
1. Store a secret in Vault
vault kv put secret/kms/db password=my-db-password
2. Reference it in kms.toml
[db]
database_type = "postgresql"
postgres_url = "postgresql://kms:secret://secret/kms/db#password@db.internal:5432/kms"
Or for a standalone field:
[db]
database_type = "postgresql"
postgres_url = "secret://secret/kms/postgres-url#value"
3. Start the KMS
export VAULT_ADDR=http://vault.internal:8200
export VAULT_TOKEN=s.xxxxxxxx
cosmian_kms --backend vault -c /etc/cosmian/kms.toml
AWS SSM Parameter Store
Fetches a SecureString parameter. The leading / is prepended automatically — do not include it in the URI.
1. Store a secret in SSM
aws ssm put-parameter \
--name /kms/db-password \
--value "my-db-password" \
--type SecureString \
--region eu-west-1
2. Reference it in kms.toml
[db]
postgres_url = "secret://eu-west-1/kms/db-password"
3. Start the KMS
export AWS_ACCESS_KEY_ID=AKIA...
export AWS_SECRET_ACCESS_KEY=...
# Optional: export AWS_SESSION_TOKEN=...
cosmian_kms --backend aws-ssm -c /etc/cosmian/kms.toml
Azure Key Vault
Uses service-principal client credentials (OAuth2) to authenticate to Azure AD, then fetches the secret from the Key Vault REST API (v7.4).
1. Store a secret
az keyvault secret set \
--vault-name myvault \
--name db-password \
--value "my-db-password"
2. Reference it in kms.toml
[db]
postgres_url = "secret://myvault/secrets/db-password"
To pin a specific version:
postgres_url = "secret://myvault/secrets/db-password/abc123def456"
3. Start the KMS
export AZURE_TENANT_ID=...
export AZURE_CLIENT_ID=...
export AZURE_CLIENT_SECRET=...
cosmian_kms --backend azure-kv -c /etc/cosmian/kms.toml
Eviden KMS (self-referencing)
Use another Eviden KMS instance as the secret store. The secret must be stored as a SecretData or OpaqueObject whose raw bytes are the UTF-8 value.
This is useful for hierarchical deployments where a "vault KMS" holds credentials used by downstream KMS instances.
1. Import a secret into the vault KMS
ckms secret-data create --value "my-db-password" --type password
# → UniqueIdentifier: 550e8400-e29b-41d4-a716-446655440000
2. Reference it in kms.toml
[db]
postgres_url = "secret://vault-kms.internal:9998/550e8400-e29b-41d4-a716-446655440000"
For localhost (uses http automatically):
postgres_url = "secret://localhost:9998/550e8400-e29b-41d4-a716-446655440000"
3. Start the KMS
# Optional token if the vault KMS requires authentication:
export COSMIAN_KMS_SECRET_TOKEN=eyJhbGciOi...
# Accept self-signed certs (dev only):
export COSMIAN_KMS_INSECURE_CERTS=true
cosmian_kms --backend cosmian-kms -c /etc/cosmian/kms.toml
Client configuration (ckms.toml)
The same secret:// URIs work in ckms.toml, for ckms, for the PKCS#11 library
(Oracle TDE, SAP ASE, …) and for the CNG key storage provider.
- Select the backend with the
CKMS_SECRET_BACKENDenvironment variable (vault | aws-ssm | azure-kv | cosmian-kms). There is no command-line flag, andKMS_SECRET_BACKENDonly applies to the server. - The backend credentials use the same environment variables as the server
(
VAULT_ADDR,VAULT_TOKEN,AWS_*,AZURE_*,COSMIAN_KMS_SECRET_TOKEN, …).
[http_config]
server_url = "https://kms.example.com"
access_token = "secret://secret/kms/ckms#token"
tls_client_pkcs12_path = "/path/to/client.p12"
tls_client_pkcs12_password = "secret://secret/kms/ckms#p12_password"
export CKMS_SECRET_BACKEND=vault
export VAULT_ADDR=https://vault.example.com:8200
export VAULT_TOKEN=...
ckms sym keys create
Values are resolved in memory each time the configuration is loaded and are never written back:
fields a command does not change keep their secret:// references in the file. ckms logout
and a token obtained by ckms login replace the value of the field they change (access_token,
refresh_token). When CKMS_SECRET_BACKEND is unset, secret:// strings are used
as they are. A secret that cannot be fetched is an error (for the PKCS#11 library,
CKR_FUNCTION_FAILED with the reason in the library log).
For the PKCS#11 library running inside Oracle, set these variables in the Oracle process environment: see Making variables persistent for the Oracle Database process.
Vault-compatible KV Secret Store
For an end-to-end walkthrough with the bao CLI, see OpenBao, Part 2. To publish credentials rotated outside the KMS to this store, see SSH certificates and external secret rotation.
The KMS can expose a Vault KV v2-compatible secret store backed by KMIP SecretData objects. Enable it in the server configuration:
[kv]
kv_enabled = true
kv_mount = "kv"
kv_ttl_check_interval_secs = 30
The KV routes apply the same CORS policy as the main KMS API (cors_allowed_origins); Vault and OpenBao clients do not need CORS.
The API is available below /<kv_mount>/data/* and /<kv_mount>/metadata/*, and also below /v1/<kv_mount>/... because the vault and bao CLIs always send the /v1 prefix. Writes are accepted with POST or PUT. The kv_mount name must be a single path segment different from vault_transit_mount and vault_pki_mount; the server refuses to start otherwise. The mount only claims its own data/ and metadata/ sub-paths, so a name that equals another scope (for example health) never hides that scope's routes. An empty value means kv. A write creates a new version, while reads return the latest version unless ?version=<number> is provided. All versions are retained indefinitely. Metadata listing uses GET /<kv_mount>/metadata/<prefix>?list=true. Paths and listing prefixes are limited to 219 characters so generated tags fit the SQL backends.
KV operations use the metadata object's access rights:
| KV operation | Required KMIP access right |
|---|---|
| Write a secret | Import |
| Read a secret | Get |
| Read metadata or list paths | Locate |
| Soft-delete or hard-delete | Destroy |
A Get grant also allows reading metadata and listing, as elsewhere in the KMS. Writes and deletes require the exact Import or Destroy grant: a read-only grantee cannot replace or delete a secret.
The first writer owns the path. Other identities must receive the matching access right on the metadata object through the normal access-grant API. A grantee that writes to a path someone else owns must also send options.expected_owner naming that owner (ckms kv put --expected-owner), otherwise the write is refused; on a new path expected_owner, if sent, must name the caller. When role enforcement is on, every write (new path or new version) is checked as a KMIP Import: an Operator needs the Create permission, and an Operator without it gets 403 permission denied even on a path it was granted Import on. A missing path and a path the caller may not use both answer 403 permission denied. A DELETE on data/<path> soft-deletes the current version; a DELETE on metadata/<path> destroys all versions and the metadata object. Destroyed versions have their secret bytes wiped, as with the KMIP Destroy operation. Hard-deleted paths no longer appear in metadata listings. Listing is available as GET metadata/<prefix>?list=true and as the Vault LIST verb; an empty listing answers 404. A path holds at most 1,000 versions (further writes answer 400 until the path is hard-deleted), and a listing that would exceed 10,000 candidates answers 400.
Concurrent writes to the same path use a metadata compare-and-swap. If another write wins first, the request returns 409 Conflict and can be retried. options.cas is honoured as in Vault KV v2: 0 writes only if the path does not exist, N only if the current version is N. Version object IDs are recorded in metadata so hard-delete does not depend on a current tag-index listing. A path's metadata object lives on an identifier derived from the path with a server key (stored once in the database parameters table as kv_metadata_uid_key, which KMIP clients cannot read). Clients can choose the identifier of the objects they create, but cannot compute that identifier, and tags starting with _ are rejected or stripped on Create, Register and Import, so they can neither take over nor block a path.
An optional write TTL (a positive duration such as 30s, 5m, 1h or 2d) can be supplied with the Vault KV v2 request body. The background sweep destroys expired versions, wiping their secret bytes, at the configured kv_ttl_check_interval_secs interval. Set the interval to 0 to disable the sweep.
When the Vault-compatible authentication API is enabled and an auth-verifier URL is configured, requests may authenticate with the X-Vault-Token header. Native KMS authentication methods remain available on the same scope.
Use the OpenBao CLI with the supported KV v2 operations by pointing it at the KMS and using the kv mount:
export BAO_ADDR=https://kms.example.com:9998
export BAO_TOKEN=<Vault token, see "Authenticating the bao CLI" below>
bao kv put kv/myapp/config api_key=xyz
bao kv get kv/myapp/config
bao kv get -version=1 kv/myapp/config
bao kv list kv/myapp
Internal record identifiers
The KMS keeps some of its own state as ordinary KMIP objects: the KV path metadata and the SSH CA and role records. KMIP clients may choose the UID of the objects they create, so a predictable UID such as kv/<path> would let a client pre-create an object there and block the path or the SSH configuration. The KMS therefore uses the first 16 bytes of HMAC-SHA256(server key, domain || record name) as the UID of these records.
The server key is 32 random bytes from the KMS RNG, stored in the parameters table (kv_metadata_uid_key), which no KMIP operation can read or write. The leader region initializes or validates it at startup, before serving requests. Instances sharing one database use the same persisted key: the first stored value wins. In a multi-region deployment, followers only read the replicated key; if it has not arrived yet, KV/SSH requests return a retry error without generating a competing value.
The same key also derives the tag that marks KV versions carrying a TTL, so that no client can make the TTL sweep visit its own objects. The key only names and marks internal records: it encrypts nothing and never touches secret material.
Authenticating the bao CLI
The BAO_TOKEN is a Vault token that a verifier configured with vault_auth_verifier_url accepts. The KMS validates it with GET <url>/v1/auth/token/lookup-self and forwards /v1/auth/* (the login requests) to <url>/v1/auth/* unchanged. The URL is the base URL of the verifier, with no /v1 suffix. It must use https:// (http:// only for a loopback host), otherwise the server refuses to start; redirects are not followed. There are two cases.
With an existing OpenBao or Vault server. Set vault_auth_verifier_url to that server's base URL. Users log in to their OpenBao as usual, or through the KMS since /v1/auth/* is forwarded, then use the same token with BAO_ADDR=<KMS>.
With the Cosmian Auth Verifier only. Set vault_auth_verifier_url to the Auth Verifier and vault_userpass_realm in the Auth Verifier configuration (the realm whose userpass accounts may log in). It needs the Auth Verifier version that serves /v1/auth/*.
- Humans:
BAO_ADDR=<KMS> bao login -method=userpass username=<user>. - Machines:
BAO_ADDR=<KMS> bao write auth/approle/login role_id=<ROLE_ID> secret_id=<SECRET_ID>. - The KMS identity is
spire:userpass:<realm>:<user>for users andspire:<role>for AppRoles.
The OpenBao CLI integration test runs in CI with both FIPS and non-FIPS builds. It covers the operations listed above, but does not claim full Vault KV v2 API parity. Partial updates (kv patch) and version-targeted delete/undelete/destroy operations are not implemented.
Security considerations
| Concern | Mitigation |
|---|---|
| Secret exposure in config files | Only secret:// references are stored on disk — never plaintext values. |
| Secret lifetime | URIs are resolved once at startup. Resolved values live only in process memory. |
| Backend credentials | Always inject via environment variables, never in the TOML file. |
| Network security | Use TLS for all backend communication. For Vault and Eviden KMS, ensure VAULT_ADDR uses https:// in production. |
| Rotation | Restart the KMS to pick up rotated secrets. There is no hot-reload. |