> ## Documentation Index
> Fetch the complete documentation index at: https://sariva.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# file:// and env:// references

> The VM-native credential reference schemes — a JSON file on the host or a named environment variable, for per-cluster and org-level Kafka credentials.

Use this page on the [Linux VM (Docker)](https://sariva.mintlify.site/deploy/vm-docker-cc.md) path, where there is no Kubernetes Secret and usually no AWS credential store. The same rule applies as everywhere else: **Sariva stores only a reference** — a path or a variable *name* — and reads the value fresh when it needs it. The secret itself stays in a file you control, or in the container's environment.

| Scheme | Reference form | The secret lives in |
| - | - | - |
| `file://` *(recommended)* | `file:///app/secrets/creds.json` — everything after the scheme is the absolute **in-container** path, verbatim | A JSON file in `./secrets/` on the host — the wizard-emitted compose mounts that directory read-only at `/app/secrets` |
| `env://` | `env://SARIVA_KAFKA_CREDS` — the *name* of an environment variable | The container's process environment (e.g. a line in `.env`) |

Both carry the same payload as every other credential store: **a single JSON object**.

```json theme={null}
{
  "api_key": "<observability-kafka-api-key>",
  "api_secret": "<observability-kafka-api-secret>"
}
```

| Where the reference goes | Keys the JSON object must carry |
| - | - |
| Per-cluster `credentials_ref`, `auth_type: api_key` (Confluent Cloud) | `api_key`, `api_secret` |
| Per-cluster `credentials_ref`, `auth_type: sasl_ssl_plain` / `sasl_ssl_scram` | `username`, `password` |
| Org-level `cc_org_credentials_ref` (Confluent Cloud control plane: cluster metadata, Metrics API) | `cc_api_key`, `cc_api_secret` (the `api_key` / `api_secret` names are also accepted) |
| Org-level `tls_credentials_ref` (CA bundle for mTLS / SASL\_SSL with a private CA) | The PEM entries the auth type needs, e.g. `ca.cert.pem` |

A `keys:` remap is available if your file uses different field names — same semantics as the AWS stores.

## file:// — drop the file in `./secrets/`, reference the container path

The reference is resolved **inside the container**, so the path must exist there. The wizard-emitted `docker-compose.yml` already mounts `./secrets` (next to the compose file) read-only at `/app/secrets` — no compose edit needed. Put the JSON file there:

```bash theme={null}
cat > secrets/creds.json <<'EOF'
{"api_key": "<key>", "api_secret": "<secret>"}
EOF
chmod 600 secrets/creds.json
```

Then use `file:///app/secrets/creds.json` — the **in-container** path, never the host path — as the credential reference: in the wizard's **Connect existing clusters** step (Step 4 on the VM path), in `sariva cluster register` ([VM page, section 7](https://sariva.mintlify.site/deploy/vm-docker-cc.md#7-connect-a-cluster)), or on an already-running platform:

```bash theme={null}
sariva cluster patch \
  --alias <cluster> \
  --credentials-ref file:///app/secrets/creds.json \
  --api-url "http://localhost:8000"
```

(A file mounted anywhere else works the same way — add your own volume line and reference that in-container path. Docker **Swarm secrets** are the standing example: a secret mounted at `/run/secrets/<name>` is just a file — reference it as `file:///run/secrets/<name>`.)

**Rotation:** the file is re-read on every resolve. Write the new key to the file and the next connection uses it — no restart.

## env:// — a variable in the container environment

Add the JSON payload as one variable in `.env` (single-line JSON):

```bash theme={null}
SARIVA_KAFKA_CREDS={"api_key": "<key>", "api_secret": "<secret>"}
```

and reference it as `env://SARIVA_KAFKA_CREDS`. The *name* is the reference; the value is read fresh from the process environment on every resolve.

**Rotation:** the container's environment is fixed at start, so rotating an `env://` value means updating `.env` and restarting the container (`docker compose up -d` after the edit).

⚠WARNING

**Prefer `file://`.** An `env://` value is visible to anyone who can run `docker inspect` on the container or read the process environment on the host — environment variables are not a secret store, they're just convenient. `file://` with `chmod 600` keeps the value out of both.

## File permissions: warn, not refuse

If a `file://` credential file is group- or world-readable, Sariva logs a **warning** (`consider chmod 600`) and proceeds — it never refuses the file. Two reasons, both deliberate:

* **The VM is the trust boundary** for `file://` references. Anyone with shell access to the host already owns every secret on it; refusing a mode adds ceremony, not security.
* **Refusing would break Swarm-mode compose secrets**, which Docker mounts read-only at mode `0444` — a hard failure there would make the most secret-conscious setup the one that doesn't work.

Keep hand-managed files at `600` anyway; the warning exists so a stray `644` gets noticed.

## Gate failures

The credential gate validates the reference eagerly at register/patch time. Errors carry the exception **type name only** — never the secret value:

| Reason code | Cause | Fix |
| - | - | - |
| `credentials_resolve_failed: FileNotFoundError` | Path wrong, or the file isn't mounted into the container | Check the compose volume line and use the **in-container** path |
| `credentials_resolve_failed: JSONDecodeError` | The file/variable isn't a valid single JSON object | One JSON object, double-quoted keys, no trailing shell quoting |
| `credentials_resolve_failed: KeyError` | The `env://` variable is not set in the container environment | Add it to `.env` and restart the container |
| `credentials_payload_shape_mismatch` | JSON is valid but missing the required keys for the declared `auth_type` | Match the key table above, or add a `keys:` remap |

## Continue

> [card] [Back to the VM path](https://sariva.mintlify.site/deploy/vm-docker-cc.md)
>
> Return to the Linux VM (Docker) + Confluent Cloud checklist.

> [card] [Connecting clusters overview](https://sariva.mintlify.site/connecting-clusters/overview.md)
>
> Registration, patching, and every credential-reference format.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.