Skip to content

self-managed: trust additional CA certificates from the Materialize resource - #40713

Open
Alphadelta14 wants to merge 6 commits into
MaterializeInc:mainfrom
Alphadelta14:heatherlapointe/dep-486-self-managed-trust-custom-ca
Open

Alphadelta14 wants to merge 6 commits into
MaterializeInc:mainfrom
Alphadelta14:heatherlapointe/dep-486-self-managed-trust-custom-ca

Conversation

@Alphadelta14

@Alphadelta14 Alphadelta14 commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

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 Materialize resource 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.additionalTrustBundle to the Materialize resource, 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.

spec:
  additionalTrustBundle:
    configMapKeyRef: { name: private-ca, key: ca.crt } # or secretKeyRef
  • orchestratord mounts the key into environmentd at /etc/materialize/additional-trust-bundle/ca.crt and passes --additional-trust-bundle and --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::new now returns a Result to carry that error.
  • environmentd's Kubernetes orchestrator mounts the same key into every clusterd pod and passes --additional-trust-bundle.
  • environmentd and clusterd handle --additional-trust-bundle before the Tokio runtime starts, without OpenSSL. They load the system CAs with rustls-native-certs, check each additional certificate as a rustls trust anchor, write both with the pem crate to a temporary file created exclusively under a random name, and point SSL_CERT_FILE at it. OpenSSL's default verify paths, openssl-probe (native-tls), rustls-native-certs and rustls-platform-verifier all 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 /tmp is an emptyDir that outlives container restarts, so the entrypoints remove bundles that earlier runs left there.
  • Kafka: librdkafka ignores SSL_CERT_FILE when it finds a bundle at one of its built-in paths. Kafka connections without SSL CERTIFICATE AUTHORITY now pass SSL_CERT_FILE as ssl.ca.location when 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_conversion covers 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, and additional_trust_bundle_keeps_system_roots, which completes TLS handshakes against servers signed by a stand-in system CA and by the additional CA. TestCa now 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: new test-kafka-additional-trust-bundle.td, run against a Materialize started with --additional-trust-bundle set 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.td already checks that the same connection fails without the bundle.
  • New orchestratord workflow oidc-auth-tls with nightly step orchestratord-oidc-auth-tls. The OIDC provider serves a certificate from a throwaway CA that Materialize trusts through additionalTrustBundle. The test checks OIDC login, and that environmentd and every clusterd pod mount the bundle and are running.

Review notes

  • The new oidc-auth-tls workflow 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 unless serve.tls.enabled is set, even with a certificate configured.
  • The version gate assumes this ships in v26.54. If it misses that release, update V26_54_0 in generation.rs and the workflow's minimum version.
  • The diff is about 1,050 lines, roughly a third of it end-to-end tests. It splits cleanly into the process-side flag (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 additionalTrustBundle field of the Materialize resource.

🤖 Generated with Claude Code

@Alphadelta14
Alphadelta14 marked this pull request as ready for review November 13, 2026 19:25
@Alphadelta14
Alphadelta14 requested review from a team as code owners November 13, 2026 19:25
@Alphadelta14
Alphadelta14 requested a review from jubrad November 13, 2026 19:25

@jubrad jubrad left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. One hardening suggestion, and I'd like to see the new nightly step pass before this merges — 1 blocker, 1 consideration, 1 nit.

written by claude on behalf of @jubrad

Comment thread src/tls-util/src/lib.rs Resolved
Comment thread src/orchestrator-kubernetes/src/lib.rs Resolved
@Alphadelta14
Alphadelta14 force-pushed the heatherlapointe/dep-486-self-managed-trust-custom-ca branch from a398e29 to c0efa86 Compare November 20, 2026 15:57
@Alphadelta14
Alphadelta14 force-pushed the heatherlapointe/dep-486-self-managed-trust-custom-ca branch 2 times, most recently from 379f29e to ad0d4ae Compare November 25, 2026 17:47

@bobbyiliev bobbyiliev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks. Bumped to V26_54_0, and the unit test now rejects v26.53.0.

Comment thread test/orchestratord/mzcompose.py Outdated
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")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, I think this should be v26.54.0-dev.0 too.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Alphadelta14 and others added 6 commits November 30, 2026 15:34
…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>
@Alphadelta14
Alphadelta14 force-pushed the heatherlapointe/dep-486-self-managed-trust-custom-ca branch from ad0d4ae to 39124e4 Compare November 30, 2026 21:05
@def-

def- commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

QA LLM Review

1. MEDIUM -- In-place environmentd restarts leave stale CA bundles in /tmp

src/environmentd/ci/entrypoint.sh:21

The cleanup runs once when the container starts. During a zero-downtime rollout, repeated DDL on the active generation can restart the read-only environmentd in place, leaving a full copy of the merged CA bundle in /tmp per restart. Those copies count toward the pod’s ephemeral storage limit and can cause eviction during catch-up.

Details

The DDL check requests an in-place restart at src/environmentd/src/deployment/preflight.rs:372. The shell handles exit code 75 by launching environmentd again inside the loop at src/environmentd/ci/entrypoint.sh:41, and each launch keeps a fresh file at src/tls-util/src/lib.rs:222. Move the Kubernetes bundle cleanup to the top of the loop so it runs before every launch.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants