@@ -251,29 +251,23 @@ mod tests {
251251 assert_eq ! ( message, "unsupported scheme http" ) ;
252252 }
253253
254- fn tls_config ( ) -> rustls:: ClientConfig {
255- #[ cfg( feature = "rustls-platform-verifier" ) ]
256- return rustls:: ClientConfig :: builder ( )
257- . with_platform_verifier ( )
258- . with_no_client_auth ( ) ;
259-
260- #[ cfg( feature = "rustls-native-certs" ) ]
261- return rustls:: ClientConfig :: builder ( )
262- . with_native_roots ( )
263- . unwrap ( )
264- . with_no_client_auth ( ) ;
265-
266- #[ cfg( feature = "webpki-roots" ) ]
267- return rustls:: ClientConfig :: builder ( )
268- . with_webpki_roots ( )
269- . with_no_client_auth ( ) ;
270- }
271-
272254 async fn connect (
273255 allow : Allow ,
274256 scheme : Scheme ,
275257 ) -> Result < MaybeHttpsStream < TokioIo < TcpStream > > , BoxError > {
276- let builder = HttpsConnectorBuilder :: new ( ) . with_tls_config ( tls_config ( ) ) ;
258+ let config_builder = rustls:: ClientConfig :: builder ( ) ;
259+ cfg_if:: cfg_if! {
260+ if #[ cfg( feature = "rustls-platform-verifier" ) ] {
261+ let config_builder = config_builder. with_platform_verifier( ) ;
262+ } else if #[ cfg( feature = "rustls-native-certs" ) ] {
263+ let config_builder = config_builder. with_native_roots( ) . unwrap( ) ;
264+ } else if #[ cfg( feature = "webpki-roots" ) ] {
265+ let config_builder = config_builder. with_webpki_roots( ) ;
266+ }
267+ }
268+ let config = config_builder. with_no_client_auth ( ) ;
269+
270+ let builder = HttpsConnectorBuilder :: new ( ) . with_tls_config ( config) ;
277271 let mut service = match allow {
278272 Allow :: Https => builder. https_only ( ) ,
279273 Allow :: Any => builder. https_or_http ( ) ,
0 commit comments