Skip to content

feat(nats pubsub): nats mtls config structures#26592

Open
cstyan wants to merge 3 commits into
mainfrom
callum/nats-mtls-config
Open

feat(nats pubsub): nats mtls config structures#26592
cstyan wants to merge 3 commits into
mainfrom
callum/nats-mtls-config

Conversation

@cstyan

@cstyan cstyan commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

NOTE: The changes in this PR were generated with heavy AI help. I have verified general functionality (manual test) and reviewed the code structure itself. Please nit pick both the code and implementation details if anything smells off at all.

AI summary of changes:
This branch is the mTLS config plumbing; it defines ClusterTLSOptions, the relay-URL constructor, the leaf-cert/tls.Config builder, the Options.ClusterTLS field, and the server-options branch that consumes it. It still leaves the field nil/dormant. Actually enabling mTLS (setting ClusterTLS from a real relay URL + CA at startup) is the separate cli/server.go wiring done in the integration branch (nats-mtls-integration). Also includes the IP SAN code.

cstyan and others added 3 commits June 12, 2026 17:56
Mints an ephemeral IP-SAN leaf certificate from an injected CA for mutually verified TLS on NATS cluster routes.

Co-authored-by: Mux <mux@coder.com>
Adds Options.ClusterTLS so buildServerOptions configures the route listener with the minted leaf and a 10s handshake timeout; nil preserves plaintext routes.

Co-authored-by: Mux <mux@coder.com>
…ctor

Adds ClusterTLSOptionsFromRelayURL for deriving the leaf SAN from a replica's relay URL, plus mesh tests covering TLS delivery, wrong-CA rejection, SAN mismatch, and mixed TLS/plaintext.

Co-authored-by: Mux <mux@coder.com>
@datadog-coder

datadog-coder Bot commented Jun 23, 2026

Copy link
Copy Markdown

Pipelines

⚠️ Warnings

🚦 3 Pipeline jobs failed

ci | required   View in Datadog   GitHub Actions

ci | test-go-pg-17   View in Datadog   GitHub Actions

contrib | title   View in Datadog   GitHub Actions

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 274cdcb | Docs | Give us feedback!

Comment thread coderd/x/nats/tls.go
Comment on lines +19 to +23
// leafCertValidity is how long a replica's ephemeral cluster leaf
// certificate remains valid. Leaves are minted in memory at startup and
// die with the process, so this only needs to exceed the maximum
// expected process lifetime between restarts.
const leafCertValidity = 30 * 24 * time.Hour

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

in a future branch that does all the proper wiring for CA cert rotation, the leaf cert validity will change to properly reflect the rotation so that a leaf key is only valid for a short period after the parent CA cert expires

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.

1 participant