Skip to content

Fix mDNS dial to downgrade to plaintext for insecure connections#182

Merged
danielbotros merged 1 commit into
mainfrom
fix-mdns-insecure-plaintext-downgrade
Jun 9, 2026
Merged

Fix mDNS dial to downgrade to plaintext for insecure connections#182
danielbotros merged 1 commit into
mainfrom
fix-mdns-insecure-plaintext-downgrade

Conversation

@danielbotros

@danielbotros danielbotros commented Jun 9, 2026

Copy link
Copy Markdown
Member

Problem

Dialing a local/insecure viam-server by an mDNS-discoverable name fails. viam-server advertises a loopback address over mDNS and serves plaintext gRPC there, but the mDNS branch of create_channel unconditionally forces TLS:

parts.scheme = Some(Scheme::HTTPS);
Channel::builder(uri).tls_config(tls_config)?.connect().await

so the TLS handshake always failed against the plaintext server. This regressed in #180 (RSDK-13879), which removed the earlier is_loopback -> h2c branch.

Fix

On the mDNS path, attempt TLS first (unchanged for cloud robots with real certs); if it fails and the caller allowed an insecure/downgraded connection, retry the local connection over plaintext.

Testing

  • cargo build / cargo clippy --all-features: clean (no new warnings).
  • Local/insecure viam-server dialed with and without fix to observe dial failure and fix.

The mDNS branch of `create_channel` unconditionally forced TLS, so dialing
a local/insecure viam-server — which serves plaintext gRPC on the loopback
port it advertises via mDNS — failed the TLS handshake every time. This
regressed in #180, which removed the previous loopback -> h2c branch.

When the caller allows an insecure/downgraded connection
(`DialOptions.allow_downgrade`, set from the FFI's `c_allow_insec` and in
turn the SDK's `insecure` option), retry the mDNS connection over plaintext
h2c after the TLS attempt fails — mirroring the direct-dial path and the
golang dialer's "downgrading from TLS to plaintext" behavior. Secure dials
are unchanged: TLS is still attempted first and only downgraded when the
caller opted in.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@danielbotros danielbotros requested a review from a team as a code owner June 9, 2026 14:21
@danielbotros danielbotros marked this pull request as draft June 9, 2026 14:22
@danielbotros danielbotros marked this pull request as ready for review June 9, 2026 14:59
@danielbotros danielbotros requested a review from stuqdog June 9, 2026 14:59
@danielbotros danielbotros merged commit 01da404 into main Jun 9, 2026
6 checks passed
@danielbotros danielbotros deleted the fix-mdns-insecure-plaintext-downgrade branch June 9, 2026 15:06
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.

2 participants