Repository navigation
Commit 212d0e1
authored
feat(keycloak): let the KMS proxy trust a private Vault CA (#3874)
<!-- Thank you for making a contribution! Here are some tips for you:
- Use Conventional Commits for the PR title: `type(scope): description`
- Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore
- Scopes are not an exhaustive list — pick the most specific scope for
the change and extend the list when a genuinely new area appears.
Examples:
- System components: dashboard, platform, operator, cilium, kube-ovn,
linstor, fluxcd, cluster-api
- Managed apps: postgres, mariadb, redis, kafka, clickhouse,
virtual-machine, kubernetes
- Development and maintenance: api, hack, tests, ci, docs, maintenance
- Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or
add a `BREAKING CHANGE:` footer
- If it's a work in progress, consider creating this PR as a draft.
- Don't hesistate to ask for opinion and review in the community chats,
even if it's still a draft.
- Add the label `backport` if it's a bugfix that needs to be backported
to a previous version.
-->
## What this PR does
The KMS-encrypting DB proxy could only reach a Vault whose certificate
chains to a publicly trusted root. A Vault fronted by an internal load
balancer with a self-signed certificate was therefore unreachable over
HTTPS, leaving plain HTTP as the only option for the DEK wrap/unwrap
traffic.
`encryption.kms.vault` now accepts the CA either inline as `caBundle`
(the chart renders the Secret) or as an already-seeded `caSecretName`,
with `caSecretKey` naming the key to project.
The CA reaches the proxy as `SSL_CERT_FILE` **and** `SSL_CERT_DIR`.
`SSL_CERT_FILE` on its own would only *add* the CA to the roots the
image ships: `crypto/x509` replaces its file list but then scans
`SSL_CERT_DIR` unconditionally, and the pinned proxy image carries
`/etc/ssl/certs/ca-certificates.crt`. Setting both collapses the pool to
the mount, so the connection that guards the KEK trusts the configured
CA and nothing else.
The database leg is unaffected either way, because it never consults the
system trust store: it is plaintext today, and will verify against an
explicit `RootCAs` pool once `KKP_BACKEND_CA_FILE` is wired.
Supporting guarantees: a non-PEM `caBundle` fails the render instead of
being dropped silently at runtime; rotating an inline `caBundle` rolls
the pods through a `checksum/vault-ca` annotation, since Go memoizes its
root pool per process; both CA keys are inert unless
`kms.backend=vault-transit`, matching every other `vault.*` key; and
setting `caBundle` together with `caSecretName` fails the render instead
of silently picking one.
Existing installations are unaffected: with neither key set the proxy
keeps using the image's system trust store, and no volume or env var is
added.
### Screenshots
<!-- REQUIRED for UI changes: attach screenshots or screen recordings
demonstrating
the visual impact of your changes. PRs with UI changes without
screenshots will not be merged. -->
### Downstream repositories
<!--
Cozystack is upstream for repositories that are NOT kept in sync with it
automatically, and nothing in CI compares the two sides, so a change
here can break them silently.
Which change forces what, and which file to touch, is the trigger map in
docs/agents/contributing.md under "Downstream Repositories". Walk it
before you tick anything.
IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM
TO FILL IN:
1. Walk the trigger map against the actual diff of this PR, file by
file. Do not decide from the PR title or from your memory of what you
changed.
2. For every repository you tick, open the follow-up PR there and link
it on the same line. A ticked box with no link claims work that does not
exist, which is worse than an empty box. Search that repository for an
open PR or issue covering it first, and link that instead of filing a
duplicate.
3. When the follow-up is out of scope, or needs a decision that is not
yours to make, open an issue in that repository instead, link that, and
say so in the PR body. Do not push a speculative PR into another
repository just to fill a line here.
4. Do not tick "No downstream repository is affected" to make the
checklist go away. If you are unsure, leave every box empty and say so
in the PR body, so a human decides.
-->
- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
### Release note
<!-- Write a release note:
- Explain what has changed internally and for users.
- Start with the same `type(scope):` prefix as in the PR title
- Follow the guidelines at
https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md.
-->
```release-note
feat(keycloak): the KMS-encrypting DB proxy can now trust a private CA for Vault, supplied inline as encryption.kms.vault.caBundle or as a pre-seeded Secret via encryption.kms.vault.caSecretName (encryption.kms.vault.caSecretKey names the key). The Vault connection is pinned to that CA alone, which makes a Vault behind an internal load balancer with a self-signed certificate reachable over HTTPS instead of plain HTTP.
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Added Vault TLS CA configuration for encrypted deployments.
* Supports inline certificate bundles or existing Secrets with a
configurable key.
* Configured secure Vault connections to use the selected CA
certificate.
* **Bug Fixes**
* Rejects invalid certificate bundles and prevents conflicting CA
sources.
* Restricts custom CA settings to Vault Transit connections.
* Preserves the system trust store when no custom CA is configured.
* Triggers pod rollouts when inline CA bundles change.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->3 files changed
Lines changed: 489 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | | - | |
| 16 | + | |
16 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
17 | 54 | | |
18 | 55 | | |
19 | 56 | | |
| |||
39 | 76 | | |
40 | 77 | | |
41 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
42 | 90 | | |
43 | 91 | | |
44 | 92 | | |
| |||
66 | 114 | | |
67 | 115 | | |
68 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
69 | 125 | | |
70 | 126 | | |
71 | 127 | | |
| |||
132 | 188 | | |
133 | 189 | | |
134 | 190 | | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 191 | + | |
| 192 | + | |
139 | 193 | | |
140 | 194 | | |
141 | 195 | | |
142 | 196 | | |
143 | 197 | | |
144 | 198 | | |
145 | 199 | | |
146 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
147 | 213 | | |
148 | 214 | | |
149 | 215 | | |
| |||
158 | 224 | | |
159 | 225 | | |
160 | 226 | | |
161 | | - | |
| 227 | + | |
162 | 228 | | |
163 | 229 | | |
164 | 230 | | |
| |||
202 | 268 | | |
203 | 269 | | |
204 | 270 | | |
205 | | - | |
| 271 | + | |
206 | 272 | | |
| 273 | + | |
207 | 274 | | |
208 | 275 | | |
209 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
210 | 283 | | |
211 | | - | |
| 284 | + | |
212 | 285 | | |
| 286 | + | |
213 | 287 | | |
214 | 288 | | |
215 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
216 | 305 | | |
217 | 306 | | |
218 | 307 | | |
| |||
0 commit comments