Skip to content

Commit 67e2ef9

Browse files
vigneshs-12vigneshwar-sm-11323LucioFranco
authored
fix: tls config overwrite in endpoint (#2252)
* fix: tls config overwrite in endpoint PR #1866 fixed the breaking change introduced in #1731, but resets the TLS config without checking if `tls` is set. This patch resolves the regression and restores expected behaviour. * fix: cargo fmt whitespace check --------- Co-authored-by: vigneshwar.sm <vigneshwar.sm@zohocorp.com> Co-authored-by: Lucio Franco <luciofranco14@gmail.com>
1 parent eeac1d3 commit 67e2ef9

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

tonic/src/transport/channel/endpoint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl Endpoint {
6262
let me = dst.try_into().map_err(|e| Error::from_source(e.into()))?;
6363
#[cfg(feature = "_tls-any")]
6464
if let EndpointType::Uri(uri) = &me.uri {
65-
if uri.scheme() == Some(&http::uri::Scheme::HTTPS) {
65+
if me.tls.is_none() && uri.scheme() == Some(&http::uri::Scheme::HTTPS) {
6666
return me.tls_config(ClientTlsConfig::new().with_enabled_roots());
6767
}
6868
}

tonic/src/transport/channel/tls.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,13 @@ impl ClientTlsConfig {
113113

114114
/// Activates all TLS roots enabled through `tls-*-roots` feature flags
115115
pub fn with_enabled_roots(self) -> Self {
116-
let config = ClientTlsConfig::new();
116+
let config = self;
117+
117118
#[cfg(feature = "tls-native-roots")]
118119
let config = config.with_native_roots();
119120
#[cfg(feature = "tls-webpki-roots")]
120121
let config = config.with_webpki_roots();
122+
121123
config
122124
}
123125

0 commit comments

Comments
 (0)