tonic icon indicating copy to clipboard operation
tonic copied to clipboard

"_tls-any" feature needs to be properly documented Or disabled with custom connector

Open rishiranjansingh opened this issue 7 months ago • 1 comments

Bug Report

Version

Platform

Everywhere

Crates

Tonic

Description

I was using my own TlsConnector with tonic 0.12.x "tls" feature enabled. But I was getting following HttpsUriWithoutTlsSupport error.

This is our code:

.connect_with_connector(connector)```

When we create endpoint and tls feature is enabled => then a None "tls" is attached to the connector. Here is the code: https://github.com/hyperium/tonic/blob/e4ba8b5c0cd1607a80ccfed7988c6874fa99ff38/tonic/src/transport/channel/endpoint.rs#L82

When we call `connect_with_connector` it wraps our PSK connector in another connector : https://github.com/hyperium/tonic/blob/e4ba8b5c0cd1607a80ccfed7988c6874fa99ff38/tonic/src/transport/channel/endpoint.rs#L477

Here is the method: https://github.com/hyperium/tonic/blob/e4ba8b5c0cd1607a80ccfed7988c6874fa99ff38/tonic/src/transport/channel/endpoint.rs#L408

Newly created wrapper connector has the "tls" field set to None. Because the endpoint had the "tls" field set to None.
On that connector when a call() method is called, Then it basically checks for None tls and returns
`HttpsUriWithoutTlsSupport`
So this issue happened because on enabling the "tls" flag. The tonic was wrapping our PSKConnector with its own connector which had Empty/None tls config. And it was throwing error from this location: https://github.com/hyperium/tonic/blob/e4ba8b5c0cd1607a80ccfed7988c6874fa99ff38/tonic/src/transport/channel/service/connector.rs#L68 

I think this wrapping is wrong. When user has provided their own connector then there should be any reason to wrap it and add your own tls.

rishiranjansingh avatar May 18 '25 20:05 rishiranjansingh

I think if you are using a custom tls connector then you don't need the tls feature? If there is a documentation gap here I would happily accept a PR.

LucioFranco avatar May 19 '25 10:05 LucioFranco