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

# Configuración del broker

> Referencia completa de broker.yml — cada campo, valor por defecto y restricción.

Esta página documenta cada campo de `broker.yml`. La fuente autoritativa es [`schemas/broker.schema.json`](https://github.com/TaconeoMental/Certplane/blob/main/schemas/broker.schema.json).

Claves obligatorias de nivel superior: `server`, `policy`, `issuer`.

## `server`

```yaml theme={null}
server:
  address: "0.0.0.0:8443"
  tls:
    cert: /etc/certplane/tls/broker.crt
    key:  /etc/certplane/tls/broker.key
    min_version: "1.2"
  mtls:
    agent_ca_bundle: /etc/certplane/ca/agent-identity-ca-bundle.crt
  read_header_timeout: 5s
  read_timeout: 10s
  write_timeout: 60s
  idle_timeout: 120s
```

| Campo                  | Tipo               | Por defecto | Notas                                                 |
| ---------------------- | ------------------ | ----------- | ----------------------------------------------------- |
| `address`              | string             | `:8443`     | Dirección de escucha.                                 |
| `tls.cert`             | string             | —           | **Obligatorio.** Certificado PEM.                     |
| `tls.key`              | string             | —           | **Obligatorio.** Clave PEM.                           |
| `tls.min_version`      | enum: `1.2`, `1.3` | `1.2`       | Versión mínima TLS.                                   |
| `mtls.agent_ca_bundle` | string             | —           | **Obligatorio.** Bundle de CA para verificar agentes. |
| `read_header_timeout`  | duration           | `5s`        |                                                       |
| `read_timeout`         | duration           | `10s`       |                                                       |
| `write_timeout`        | duration           | `60s`       |                                                       |
| `idle_timeout`         | duration           | `120s`      |                                                       |

## `policy`

```yaml theme={null}
policy:
  path: /etc/certplane/policy.yml
  watch: true
```

| Campo   | Tipo   | Por defecto | Notas                                      |
| ------- | ------ | ----------- | ------------------------------------------ |
| `path`  | string | —           | **Obligatorio.**                           |
| `watch` | bool   | `false`     | Recarga la política al cambiar el archivo. |

Semántica del archivo en [Resumen de política](/es/policy/overview).

## `issuer`

`acme` es actualmente el único provider.

```yaml theme={null}
issuer:
  provider: acme
  acme:
    directory_url: https://acme-v02.api.letsencrypt.org/directory
    account_email: admin@example.com
    account_key: /var/lib/certplane/acme/account.key
    dns_provider: cloudflare
    preferred_chain: "ISRG Root X1"
```

| Campo                  | Tipo                          | Por defecto | Notas                                                                                                          |
| ---------------------- | ----------------------------- | ----------- | -------------------------------------------------------------------------------------------------------------- |
| `provider`             | enum: `acme`                  | `acme`      |                                                                                                                |
| `acme.directory_url`   | string                        | —           | **Obligatorio.** Staging para pruebas: `https://acme-staging-v02.api.letsencrypt.org/directory`.               |
| `acme.account_email`   | string                        | —           | **Obligatorio.**                                                                                               |
| `acme.account_key`     | string                        | —           | **Obligatorio.** Ruta a la clave privada de la cuenta ACME (la crea el broker en el primer arranque si falta). |
| `acme.dns_provider`    | enum: `cloudflare`, `httpreq` | —           | **Obligatorio.** Provider DNS para `dns-01`.                                                                   |
| `acme.preferred_chain` | string                        | —           | Opcional.                                                                                                      |

Las credenciales del provider DNS se resuelven vía `secrets` — ver más abajo y [Let's Encrypt + dns-01](/es/guides/lets-encrypt-dns).

## `secrets`

```yaml theme={null}
secrets:
  provider: env       # env | file | vault | openbao
  vault:
    address: https://vault.int.example.com:8200
    token_file: /etc/certplane/vault-token
    mount_path: secret
    kv_version: 2
    key: value
    timeout: 10s
    namespace: ""
```

| Campo              | Tipo                                    | Por defecto | Notas                                |
| ------------------ | --------------------------------------- | ----------- | ------------------------------------ |
| `provider`         | enum: `env`, `file`, `vault`, `openbao` | `env`       |                                      |
| `vault.address`    | string                                  | —           | Obligatorio con `vault` u `openbao`. |
| `vault.token`      | string                                  | —           | Token inline. Evítalo en producción. |
| `vault.token_file` | string                                  | —           | Archivo con el token. Preferido.     |
| `vault.mount_path` | string                                  | `secret`    |                                      |
| `vault.kv_version` | enum: `1`, `2`                          | `2`         |                                      |
| `vault.key`        | string                                  | `value`     | Clave dentro del secreto.            |
| `vault.timeout`    | duration                                | `10s`       |                                      |
| `vault.namespace`  | string                                  | —           | Solo Vault Enterprise.               |

Ver [Secretos en Vault y OpenBao](/es/guides/vault-secrets).

## `store`

```yaml theme={null}
store:
  driver: sqlite              # sqlite | file
  path: /var/lib/certplane/broker.db
```

El store cachea certificados emitidos y eventos de auditoría.

| Campo    | Tipo                   | Por defecto                    | Notas                  |
| -------- | ---------------------- | ------------------------------ | ---------------------- |
| `driver` | enum: `sqlite`, `file` | `sqlite`                       |                        |
| `path`   | string                 | `/var/lib/certplane/broker.db` | Archivo SQLite o JSON. |

## `audit`

```yaml theme={null}
audit:
  enabled: true
  failure_mode: fail_open     # fail_open | fail_closed
  mirror_to_log: false
```

| Campo           | Tipo | Por defecto | Notas                                                                                        |
| --------------- | ---- | ----------- | -------------------------------------------------------------------------------------------- |
| `enabled`       | bool | `true`      |                                                                                              |
| `failure_mode`  | enum | `fail_open` | Si falla el registro de auditoría, `fail_closed` rechaza la emisión; `fail_open` la permite. |
| `mirror_to_log` | bool | `false`     | Emite cada evento también como línea de log estructurado.                                    |

Inspecciónalos con `certplane-broker -c <config> audit tail`.

## `rate_limits`

```yaml theme={null}
rate_limits:
  per_identity_per_hour: 50
  per_identity_profile_per_hour: 20
```

`0` desactiva el límite. Negativos son inválidos.

## `logging`

```yaml theme={null}
logging:
  level: info        # debug | info | warn | error
  format: json       # text | json
  destination: stdout  # stdout | stderr
```

Defaults del broker: `info`, `json`, `stdout`.

## Validación

`certplane-broker` rechaza la configuración al arrancar si:

* Falta cualquier campo obligatorio.
* `tls.min_version` no es `1.2` ni `1.3`.
* Falta un campo ACME exigido por `provider: acme`.
* `secrets.provider` es `vault`/`openbao` sin `vault.address` o con `kv_version` inválido.
* `store.driver` no es `sqlite` ni `file`.
* `audit.failure_mode` no es `fail_open` ni `fail_closed`.
* Algún rate-limit es negativo.

Los errores se acumulan y se reportan juntos.
