@@ -245,29 +245,23 @@ mod tests {
245245 assert_eq ! ( message, "unsupported scheme http" ) ;
246246 }
247247
248- fn tls_config ( ) -> rustls:: ClientConfig {
249- #[ cfg( feature = "rustls-platform-verifier" ) ]
250- return rustls:: ClientConfig :: builder ( )
251- . with_platform_verifier ( )
252- . with_no_client_auth ( ) ;
253-
254- #[ cfg( feature = "rustls-native-certs" ) ]
255- return rustls:: ClientConfig :: builder ( )
256- . with_native_roots ( )
257- . unwrap ( )
258- . with_no_client_auth ( ) ;
259-
260- #[ cfg( feature = "webpki-roots" ) ]
261- return rustls:: ClientConfig :: builder ( )
262- . with_webpki_roots ( )
263- . with_no_client_auth ( ) ;
264- }
265-
266248 async fn connect (
267249 https_only : bool ,
268250 https : bool ,
269251 ) -> Result < MaybeHttpsStream < TokioIo < TcpStream > > , BoxError > {
270- let builder = HttpsConnectorBuilder :: new ( ) . with_tls_config ( tls_config ( ) ) ;
252+ let config_builder = rustls:: ClientConfig :: builder ( ) ;
253+ cfg_if:: cfg_if! {
254+ if #[ cfg( feature = "rustls-platform-verifier" ) ] {
255+ let config_builder = config_builder. with_platform_verifier( ) ;
256+ } else if #[ cfg( feature = "rustls-native-certs" ) ] {
257+ let config_builder = config_builder. with_native_roots( ) . unwrap( ) ;
258+ } else if #[ cfg( feature = "webpki-roots" ) ] {
259+ let config_builder = config_builder. with_webpki_roots( ) ;
260+ }
261+ }
262+ let config = config_builder. with_no_client_auth ( ) ;
263+
264+ let builder = HttpsConnectorBuilder :: new ( ) . with_tls_config ( config) ;
271265 let mut service = match https_only {
272266 true => builder. https_only ( ) ,
273267 false => builder. https_or_http ( ) ,
0 commit comments