feat(nats pubsub): nats mtls config structures#26592
Open
cstyan wants to merge 3 commits into
Open
Conversation
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>
cstyan
commented
Jun 23, 2026
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 |
Contributor
Author
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.