File tree Expand file tree Collapse file tree 2 files changed +19
-15
lines changed
tonic/src/transport/channel Expand file tree Collapse file tree 2 files changed +19
-15
lines changed Original file line number Diff line number Diff line change @@ -60,12 +60,6 @@ impl Endpoint {
6060 D :: Error : Into < crate :: BoxError > ,
6161 {
6262 let me = dst. try_into ( ) . map_err ( |e| Error :: from_source ( e. into ( ) ) ) ?;
63- #[ cfg( feature = "_tls-any" ) ]
64- if let EndpointType :: Uri ( uri) = & me. uri {
65- if uri. scheme ( ) == Some ( & http:: uri:: Scheme :: HTTPS ) {
66- return me. tls_config ( ClientTlsConfig :: new ( ) . with_enabled_roots ( ) ) ;
67- }
68- }
6963 Ok ( me)
7064 }
7165
@@ -332,14 +326,22 @@ impl Endpoint {
332326 #[ cfg( feature = "_tls-any" ) ]
333327 pub fn tls_config ( self , tls_config : ClientTlsConfig ) -> Result < Self , Error > {
334328 match & self . uri {
335- EndpointType :: Uri ( uri) => Ok ( Endpoint {
336- tls : Some (
337- tls_config
338- . into_tls_connector ( uri)
339- . map_err ( Error :: from_source) ?,
340- ) ,
341- ..self
342- } ) ,
329+ EndpointType :: Uri ( uri) => {
330+ let mut tls_config = tls_config;
331+ #[ cfg( feature = "_tls-any" ) ]
332+ if uri. scheme ( ) == Some ( & http:: uri:: Scheme :: HTTPS ) {
333+ tls_config = tls_config. with_enabled_roots ( ) ;
334+ }
335+
336+ Ok ( Endpoint {
337+ tls : Some (
338+ tls_config
339+ . into_tls_connector ( uri)
340+ . map_err ( Error :: from_source) ?,
341+ ) ,
342+ ..self
343+ } )
344+ }
343345 EndpointType :: Uds ( _) => Err ( Error :: new ( error:: Kind :: InvalidTlsConfigForUds ) ) ,
344346 }
345347 }
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments