Skip to content

feat(config): support TLS server name override for scheduler and peer clients - #2089

Open
simonepri wants to merge 3 commits into
dragonflyoss:mainfrom
simonepri:feat/scheduler-tls-server-name
Open

simonepri wants to merge 3 commits into
dragonflyoss:mainfrom
simonepri:feat/scheduler-tls-server-name

Conversation

@simonepri

@simonepri simonepri commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Description

Add an optional serverName field to the scheduler TLS config (scheduler) and the peer TLS config (upload.client). When set, load_client_tls_config uses it as the TLS domain name for verifying the scheduler, peer or seed peer certificate. When unset, behavior is unchanged: the host of the dial URL is used.

Unit tests cover deserializing serverName for both configs and that load_client_tls_config prefers it over the dial host.

Related Issue

Fixes #2088

Follow-up to #1859, which made dfdaemon dial schedulers over https when TLS is configured. With that fix in place, the handshake now reaches certificate verification, which fails against DNS-only scheduler certificates.

Motivation and Context

dfdaemon dials schedulers, peers and seed peers by IP, so it verifies their certificates against that IP. On Kubernetes, these certificates usually carry DNS SANs only, because pod and node IPs change. With mTLS on, every connection then fails with tls: bad certificate. Setting serverName to a name in the certificate lets DNS-only certificates verify, for example one shared peer certificate for every dfdaemon.

When dfdaemon connects to schedulers with TLS enabled, Scheduler::load_client_tls_config sets ClientTlsConfig::domain_name to the host of the dial URL, which is always the scheduler IP address. If the scheduler TLS certificate contains only DNS Subject Alternative Names (SANs) rather than IP SANs, TLS verification fails during handshake.

Add an optional server_name field to Scheduler config (serde serverName). When set, Scheduler::load_client_tls_config uses this value as the TLS domain name for certificate verification, falling back to the dial host IP when unset. Add unit tests for configuration deserialization and TLS domain name resolution.

Signed-off-by: Simone Primarosa <simone.primarosa@gmail.com>
@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.17%. Comparing base (3904607) to head (6e0fcc4).
⚠️ Report is 45 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2089      +/-   ##
==========================================
+ Coverage   65.29%   67.17%   +1.87%     
==========================================
  Files         103      102       -1     
  Lines       30789    32985    +2196     
==========================================
+ Hits        20105    22157    +2052     
- Misses      10684    10828     +144     
Files with missing lines Coverage Δ
dragonfly-client-config/src/dfdaemon.rs 98.28% <100.00%> (+0.28%) ⬆️

... and 41 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

dfdaemon dials peers and seed peers by IP, so UploadClient::load_client_tls_config
verifies their certificates against the peer IP. Peer certificates with DNS
SANs only fail the handshake, the same way scheduler certificates did.

Add an optional server_name field to UploadClient config (serde serverName).
When set, it is used as the TLS domain name for verifying peer certificates,
falling back to the dial host when unset.

Signed-off-by: Simone Primarosa <simone.primarosa@gmail.com>
@simonepri simonepri changed the title feat(config): support TLS server name override for scheduler client feat(config): support TLS server name override for scheduler and peer clients Oct 8, 2026
@simonepri

Copy link
Copy Markdown
Contributor Author

gaius-qi@ LunaWhispers@ small follow up of #1859 to make the mTSL setup work.

@CooooolFrog CooooolFrog added the bug Something isn't working label Nov 17, 2026

@CooooolFrog CooooolFrog left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The implementation looks good to me. Could you add a TLS handshake regression test using a server certificate with DNS SANs only, while connecting by IP?

Please cover:

No serverName override: verification fails.
Matching serverName: the handshake succeeds.
Non-matching serverName: verification still fails.

The existing tests only check that the server name ends up in the
ClientTlsConfig. They do not prove that it fixes verification of a
certificate that carries DNS SANs only when the client dials by IP.

Start a gRPC server on 127.0.0.1 with a certificate whose only SAN is a
DNS name, and dial it by IP with the scheduler and upload client TLS
configs. Without a server name, and with a non-matching one, the
handshake fails certificate verification; with a matching server name,
the handshake and a health check succeed.

Signed-off-by: Simone Primarosa <simone.primarosa@gmail.com>
@simonepri

simonepri commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Added a handshake test in 6e0fcc4: server cert with a DNS SAN only, dialed by IP. No serverName and a non-matching one fail verification, a matching one connects.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scheduler and peer mTLS fail when certificates have DNS SANs only

2 participants