Files
mesh-catalog/modules/step-ca/module.json
T
jschoubben d9fbc72565 step-ca: give the CA's own secret material to the uid the CA runs as
The upstream `smallstep/step-ca` image runs as uid 1000. An own-secret lands as
a file the host writes root:root 0600 — the module says only a name and a path,
so there is nowhere to say who must be able to read it — and the container
crash-looped on `permission denied` reading its own root key. The lab got past
it first with `chmod 0644`, which hands the root key to every local user, and
then by running the CA as root, which is worse.

Neither is needed. A module composes its own files, and a `file` resource takes
both a `mode` and an `owner`, with `${secret:name}` reaching the module's own
secrets — the mechanism redis already uses to hand its password to a server
running as 999. So the three pieces of init material are declared as owned
files: still 0600, owned by 1000:1000, and those are what the container mounts.

The raw own-secret files stay where they were. Nothing mounts them now; they are
how the secret comes to exist on the machine, and the host is the only thing
that reads them. Same shape as redis's `default.secret`.

Verified against the real code rather than by inspection: mesh-control attaches
the sealed value to each of the three resources and keeps `owner` and `mode`
(`sealedFor` + `intoFile` over this manifest), and mesh-host parses `owner` on a
sealed-substituted file and lands it 0600 owned by 1000:1000 (`applyFile`).
2026-09-10 20:57:58 +02:00

114 lines
3.2 KiB
JSON

{
"module": "step-ca",
"version": "1",
"capabilities": [
"container-runtime"
],
"provides": [
{
"name": "acme-ca",
"scope": "mesh"
}
],
"serves": {
"acme-ca": {
"path": "/acme/acme/directory",
"root": ""
}
},
"listens": [
{
"port": 9000,
"protocol": "tcp",
"from": "mesh",
"why": "the ACME directory and step-ca API; a proxy on any node reaches it here over the mesh to obtain certificates, and its single listen is what the consumer is told the port is"
}
],
"own-secrets": {
"password": "/var/lib/mesh/step-ca/password",
"root-cert": "/var/lib/mesh/step-ca/root-cert",
"root-key": "/var/lib/mesh/step-ca/root-key",
"root-key-password": "/var/lib/mesh/step-ca/root-key-password"
},
"resources": [
{
"id": "mesh-state",
"type": "directory",
"path": "/var/lib/mesh/step-ca",
"mode": "0700"
},
{
"id": "home",
"type": "directory",
"path": "/var/lib/step-ca",
"mode": "0700",
"owner": "1000:1000"
},
{
"id": "config",
"type": "file",
"path": "/var/lib/mesh/step-ca/config.json",
"mode": "0644",
"content": "{}",
"merge": "json"
},
{
"id": "init-env",
"type": "file",
"path": "/var/lib/mesh/step-ca/init.env",
"mode": "0600",
"content": "DOCKER_STEPCA_INIT_PASSWORD=${secret:password}\n"
},
{
"id": "root-cert-file",
"type": "file",
"path": "/var/lib/mesh/step-ca/root-cert.pem",
"mode": "0600",
"owner": "1000:1000",
"content": "${secret:root-cert}"
},
{
"id": "root-key-file",
"type": "file",
"path": "/var/lib/mesh/step-ca/root-key.pem",
"mode": "0600",
"owner": "1000:1000",
"content": "${secret:root-key}"
},
{
"id": "root-key-password-file",
"type": "file",
"path": "/var/lib/mesh/step-ca/root-key-password.txt",
"mode": "0600",
"owner": "1000:1000",
"content": "${secret:root-key-password}"
},
{
"id": "server",
"type": "container",
"name": "step-ca",
"image": "smallstep/step-ca@sha256:a2b17872915c193259b75a5474c398326f41bd199f0842093e52cf4182bc8270",
"network": "host",
"env-file": [
"/var/lib/mesh/step-ca/init.env"
],
"env": {
"DOCKER_STEPCA_INIT_NAME": "Mesh Internal CA",
"DOCKER_STEPCA_INIT_DNS_NAMES": "localhost,127.0.0.1",
"DOCKER_STEPCA_INIT_ACME": "true",
"DOCKER_STEPCA_INIT_REMOTE_MANAGEMENT": "false",
"DOCKER_STEPCA_INIT_ROOT_FILE": "/run/secrets/root_ca.crt",
"DOCKER_STEPCA_INIT_KEY_FILE": "/run/secrets/root_ca_key",
"DOCKER_STEPCA_INIT_KEY_PASSWORD_FILE": "/run/secrets/root_ca_key_password"
},
"volumes": [
"/var/lib/step-ca:/home/step",
"/var/lib/mesh/step-ca/root-cert.pem:/run/secrets/root_ca.crt:ro",
"/var/lib/mesh/step-ca/root-key.pem:/run/secrets/root_ca_key:ro",
"/var/lib/mesh/step-ca/root-key-password.txt:/run/secrets/root_ca_key_password:ro",
"/var/lib/mesh/step-ca/config.json:/run/config/config.json:ro"
]
}
]
}