feat(scripts): vault CA bootstrap helper for local dev#359
feat(scripts): vault CA bootstrap helper for local dev#359BjoernSchotte wants to merge 2 commits into
Conversation
The vault sidecar needs a TLS secret 'vault-ca' in the cluster and the
matching CA cert baked into the harness images' trust store.
vault/README.md documents this as five manual steps (openssl genpkey,
openssl req with three addext flags, kubectl create secret tls, plus
image rebuild). Easy to get wrong: wrong key format breaks WebCrypto
import in vault, missing extensions break GnuTLS validation, mismatched
cert vs baked-in cert breaks TLS verify silently.
bin/vault-ca-bootstrap-local.sh collapses this into one idempotent
command. It:
1. Generates a fresh CA into .local/vault/ if one isn't there
(--force regenerates on demand)
2. Syncs the cert into vault/ca.crt so the next harness build bakes
the matching CA into the image trust store
3. Creates (or recreates) the vault-ca TLS secret in the cluster
specified by KUBE_CONTEXT (default kind-agent-sbx), or skips
this step gracefully when the cluster is not yet up
Re-running is safe: existing key + cert are reused unless --force is
passed, and the cluster secret step is delete+recreate so it always
reflects the current local material.
vault/README.md gets a 'Local dev quick start' section pointing at the
script; the manual steps remain as the canonical reference.
Greptile SummaryThis PR adds
Confidence Score: 4/5Safe to merge; the script is a local-dev convenience tool with no production impact and correct cryptographic parameters. The OpenSSL commands suppress all stderr output without a fallback error handler, meaning a developer on macOS (where system openssl is LibreSSL and lacks -addext) will see the script silently exit with no explanation. The private key is also written with world-readable permissions for a brief moment before chmod 600 corrects them. Both are quality issues for a developer-facing script, not regressions in production code. bin/vault-ca-bootstrap-local.sh — the silent-failure and key-permission issues are both in the CA generation block.
|
| Filename | Overview |
|---|---|
| bin/vault-ca-bootstrap-local.sh | New idempotent CA-bootstrap script; correct OpenSSL params and kubectl flow, but openssl failures are silently swallowed by 2>/dev/null with no fallback error message, and the private key file is briefly world-readable before chmod 600. |
| vault/README.md | Adds a Local dev quick start section pointing to the new script while preserving the canonical manual steps; documentation is accurate and well-structured. |
Reviews (1): Last reviewed commit: "feat(scripts): vault CA bootstrap helper..." | Re-trigger Greptile
| openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out "$KEY" 2>/dev/null | ||
| openssl req -new -x509 -key "$KEY" -out "$CRT" -sha256 -days 3650 \ | ||
| -subj "/CN=vault/O=LiteLLM" \ | ||
| -addext "basicConstraints=critical,CA:TRUE" \ | ||
| -addext "keyUsage=critical,keyCertSign,digitalSignature" 2>/dev/null | ||
| chmod 600 "$KEY" |
There was a problem hiding this comment.
openssl genpkey creates the key file with umask-derived permissions (typically 644) before chmod 600 narrows them. On a multi-user machine the private key is briefly world-readable. Wrapping the generation in a subshell with umask 077 ensures the file is never created wider than 600.
| openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out "$KEY" 2>/dev/null | |
| openssl req -new -x509 -key "$KEY" -out "$CRT" -sha256 -days 3650 \ | |
| -subj "/CN=vault/O=LiteLLM" \ | |
| -addext "basicConstraints=critical,CA:TRUE" \ | |
| -addext "keyUsage=critical,keyCertSign,digitalSignature" 2>/dev/null | |
| chmod 600 "$KEY" | |
| (umask 077; openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out "$KEY" 2>/dev/null) \ | |
| || err "openssl genpkey failed — ensure OpenSSL ≥ 1.1.1 is installed (macOS system LibreSSL is not supported)" | |
| openssl req -new -x509 -key "$KEY" -out "$CRT" -sha256 -days 3650 \ | |
| -subj "/CN=vault/O=LiteLLM" \ | |
| -addext "basicConstraints=critical,CA:TRUE" \ | |
| -addext "keyUsage=critical,keyCertSign,digitalSignature" 2>/dev/null \ | |
| || err "openssl req -addext failed — ensure OpenSSL ≥ 1.1.1 is installed (macOS system LibreSSL is not supported)" | |
| chmod 600 "$KEY" |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Summary
vault/README.mddocuments vault CA setup as five manual steps:openssl genpkeywith specific RSA params (WebCrypto needs PKCS#8)openssl req -x509with three-addextflags (basicConstraints, keyUsage, …)kubectl create secret tls vault-cavault/ca.crtinto harness images at build timeEasy to get wrong: missing extensions silently break GnuTLS clients, wrong key format breaks vault's WebCrypto import, a stale baked-in cert silently breaks TLS verification across all sandbox traffic with no clear error.
This PR adds
bin/vault-ca-bootstrap-local.sh— a single idempotent script that does steps 1–3 and reminds the operator about step 4.Behaviour
.local/vault/tls.{key,crt}(.local/is already in.gitignore).vault/ca.crtis overwritten with the freshly generated cert so the next harness build picks it up.vault-caTLS secret is deleted + recreated on each run when the cluster is reachable, so the in-cluster material always matches what's on disk.kind-agent-sbxby default) isn't up yet, the cluster step is gracefully skipped with a reminder.Doc change
vault/README.mdgets a "Local dev quick start" section pointing at the script. The existing manual steps stay as the canonical reference so the script never becomes the only source of truth.Test plan
--force— both reused, idempotent (no rotation)--force— fresh CA, secret rotatedbin/kind-up.sh— graceful skip of the cluster step