Skip to content

Commit dcb75a0

Browse files
fix: tls config overwrite in endpoint
PR hyperium#1866 fixed the breaking change introduced in hyperium#1731, but resets the TLS config without checking if `tls` is set. This patch resolves the regression and restores expected behaviour.
1 parent 13b9643 commit dcb75a0

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)