Fix mDNS dial to downgrade to plaintext for insecure connections#182
Merged
Conversation
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>
stuqdog
approved these changes
Jun 9, 2026
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.
Problem
Dialing a local/insecure viam-server by an mDNS-discoverable name fails.
viam-serveradvertises a loopback address over mDNS and serves plaintext gRPC there, but the mDNS branch ofcreate_channelunconditionally forces TLS:so the TLS handshake always failed against the plaintext server. This regressed in #180 (RSDK-13879), which removed the earlier
is_loopback -> h2cbranch.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).