Repository navigation
self-managed: trust additional CA certificates from the Materialize resource - #40713
Alphadelta14 wants to merge 6 commits into
Conversation
a398e29 to
c0efa86
Compare
379f29e to
ad0d4ae
Compare
bobbyiliev
left a comment
There was a problem hiding this comment.
Looks great! Just the version gate, I think this one missed 26.53.
| /// `--additional-trust-bundle`, and `environmentd` learned | ||
| /// `--orchestrator-kubernetes-additional-trust-bundle`. Older images reject the | ||
| /// unknown arguments and fail to start. | ||
| static V26_53_0: LazyLock<Version> = LazyLock::new(|| Version { |
There was a problem hiding this comment.
If I read this right, v26.53.0-rc.1 is already cut without this, and main is on 26.54.0-dev.0 now. So a v26.53.x image would pass this check but reject the new flags. Maybe bump it to 26.54?
There was a problem hiding this comment.
Good catch, thanks. Bumped to V26_54_0, and the unit test now rejects v26.53.0.
| version = get_version(args.tag) | ||
| min_version = MzVersion.parse_mz("v26.16.0-dev.0") | ||
| # `additionalTrustBundle` needs v26.53. | ||
| min_version = MzVersion.parse_mz("v26.53.0-dev.0" if tls else "v26.16.0-dev.0") |
There was a problem hiding this comment.
Same here, I think this should be v26.54.0-dev.0 too.
There was a problem hiding this comment.
Done, now v26.54.0-dev.0.
| // `--additional-trust-bundle` installs. Setting the location | ||
| // alongside `ssl.ca.pem` would make a connection's own CA add | ||
| // to these CAs instead of replacing them. | ||
| options.insert("ssl.ca.location".into(), ca_file.into()); |
There was a problem hiding this comment.
Small nit: the nightly test covers OIDC, but I don't think anything exercises this Kafka path yet. Maybe worth a follow-up test with a Kafka broker signed by the extra CA?
There was a problem hiding this comment.
Added in this PR. test-kafka-additional-trust-bundle.td in kafka-auth runs against a Materialize started with the broker's CA as the trust bundle. A connection without its own CA validates and ingests through clusterd, and a connection's own CA still overrides the bundle.
…esource Add `spec.additionalTrustBundle` to the Materialize resource. It names a ConfigMap or Secret key holding PEM CA certificates. orchestratord mounts it into environmentd, environmentd mounts it into clusterd pods, and both processes merge it with the system CA bundle at startup and point SSL_CERT_FILE at the result. Kafka connections without their own CA pass SSL_CERT_FILE to librdkafka as `ssl.ca.location`. Part of DEP-486. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Load the system CAs with rustls-native-certs, validate the additional certificates as rustls trust anchors, and encode the merged bundle with the pem crate. This drops the direct openssl-probe dependency and keeps new code off OpenSSL. rustls-native-certs also reads the platform store on macOS, so the flag no longer requires SSL_CERT_FILE there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v26.52.0-rc.1 was cut without the trust bundle flags, so gate them on 26.53.0-dev.0. Gated at 26.52, orchestratord would pass the flags to v26.52 images, which reject them and fail to start. Create the merged CA bundle with tempfile, exclusively under a random name. A predictable name in a shared temporary directory let another user pre-create the file and keep write access to the CAs the process trusts. Replace the trust bundle path constant with directory and file constants, which removes splitting it at runtime. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hydra serves plain HTTP unless serve.tls.enabled is set, even with a certificate and key configured. The provider therefore never passed its HTTPS readiness probe, and the workflow timed out waiting for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The kafka-auth composition gains test-kafka-additional-trust-bundle.td. It runs against a Materialize started with `--additional-trust-bundle` set to the CA that signs the broker's certificate. A TLS connection without a CA of its own validates in environmentd and ingests through clusterd, which inherits the bundle under the process orchestrator. A connection with its own CA still trusts only that CA. The workflow restores the default Materialize afterwards, and test-kafka-ssl.td checks that the same connection fails without the bundle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v26.53 was cut without this change, and main is now v26.54.0-dev.0. A v26.53.x image would pass the v26.53 gate and then reject the new flags, so the gate and the oidc-auth-tls minimum move to v26.54. In Kubernetes, /tmp is an emptyDir that outlives container restarts, so each restart left another merged CA bundle there. The entrypoints now remove them next to the leftover SSH keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ad0d4ae to
39124e4
Compare
QA LLM Review1. MEDIUM -- In-place environmentd restarts leave stale CA bundles in
|
Motivation
Self-managed environments cannot trust a private or self-signed CA for outbound TLS. This blocks OIDC when the identity provider's certificate comes from such a CA: environmentd fails to verify it when it fetches the discovery document and JWKS. The images trust only the system bundle they ship, the
Materializeresource cannot mount extra files into environmentd, and environmentd creates clusterd pods with a fixed set of environment variables and volumes.Part of DEP-486.
Description
Adds
spec.additionalTrustBundleto theMaterializeresource, in both v1alpha1 and v1. It references a key in a ConfigMap or a Secret that holds PEM CA certificates. environmentd and clusterd trust them in addition to the CAs in their image./etc/materialize/additional-trust-bundle/ca.crtand passes--additional-trust-bundleand--orchestrator-kubernetes-additional-trust-bundle(the field as JSON). Only the referenced key is projected into the pod, so pointing at a cert-manager Secret does not mount its private key. The field requires environmentd v26.54.0-dev.0, and reconciliation fails with an error on older versions, because their images reject the new flags.generation::Resources::newnow returns aResultto carry that error.--additional-trust-bundle.--additional-trust-bundlebefore the Tokio runtime starts, without OpenSSL. They load the system CAs withrustls-native-certs, check each additional certificate as a rustls trust anchor, write both with thepemcrate to a temporary file created exclusively under a random name, and pointSSL_CERT_FILEat it. OpenSSL's default verify paths,openssl-probe(native-tls),rustls-native-certsandrustls-platform-verifierall read that variable, which covers OIDC, the schema registry, AWS, MySQL, SQL Server and Postgres. Startup fails when the bundle has no valid certificates, or when any system CA fails to load, so a bundle cannot silently replace the system CAs. In Kubernetes/tmpis an emptyDir that outlives container restarts, so the entrypoints remove bundles that earlier runs left there.SSL_CERT_FILEwhen it finds a bundle at one of its built-in paths. Kafka connections withoutSSL CERTIFICATE AUTHORITYnow passSSL_CERT_FILEasssl.ca.locationwhen it is set. Connections with their own CA still trust only that CA.When the field is unset, it is not serialized, so rollout hashes of existing environments do not change, and no volume or flag is added.
Docs and the downstream deployment changes will follow separately.
Tests
mz-cloud-resources:additional_trust_bundle_triggers_rollout_and_survives_conversioncovers the rollout hash, conversion in both directions, and rejecting a reference with both or neither key ref set.mz-orchestrator-kubernetes:additional_trust_bundle_volume_projects_only_the_referenced_key.mz-orchestratord:additional_trust_bundle_args_require_supported_version, which rejects v26.53.0 images.mz-tls-util: merge tests, including rejecting a PEM block that is not a valid certificate, andadditional_trust_bundle_keeps_system_roots, which completes TLS handshakes against servers signed by a stand-in system CA and by the additional CA.TestCanow gives each CA a distinct subject, because OpenSSL looks up issuers by subject name and same-named CAs shadow each other in one store.kafka-auth: newtest-kafka-additional-trust-bundle.td, run against a Materialize started with--additional-trust-bundleset to the CA that signs the broker. A TLS connection without its own CA validates and its source ingests through clusterd, and a connection with a different CA of its own is still rejected.test-kafka-ssl.tdalready checks that the same connection fails without the bundle.orchestratordworkflowoidc-auth-tlswith nightly steporchestratord-oidc-auth-tls. The OIDC provider serves a certificate from a throwaway CA that Materialize trusts throughadditionalTrustBundle. The test checks OIDC login, and that environmentd and every clusterd pod mount the bundle and are running.Review notes
oidc-auth-tlsworkflow passed in Nightly #18812, run before the version gate moved to v26.54 and before the latest rebase onto main. The OIDC provider serves plain HTTP unlessserve.tls.enabledis set, even with a certificate configured.V26_54_0ingeneration.rsand the workflow's minimum version.mz-tls-util, environmentd, clusterd, Kafka) and the resource plumbing (CRD, orchestrators, test) if reviewers prefer two PRs.Release notes
This release will let self-managed deployments trust additional CA certificates for outbound TLS connections, such as to an OIDC provider with a self-signed certificate, through the
additionalTrustBundlefield of the Materialize resource.🤖 Generated with Claude Code