@@ -251,29 +251,23 @@ mod tests {
251
251
assert_eq ! ( message, "unsupported scheme http" ) ;
252
252
}
253
253
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
-
272
254
async fn connect (
273
255
allow : Allow ,
274
256
scheme : Scheme ,
275
257
) -> 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) ;
277
271
let mut service = match allow {
278
272
Allow :: Https => builder. https_only ( ) ,
279
273
Allow :: Any => builder. https_or_http ( ) ,
0 commit comments