diff --git a/Cargo.toml b/Cargo.toml
index a1829a3..c971434 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -38,6 +38,7 @@ webpki-roots = { version = "0.26", optional = true }
 futures-util = { version = "0.3", default-features = false }
 
 [dev-dependencies]
+cfg-if = "1"
 http-body-util = "0.1"
 hyper-util = { version = "0.1", default-features = false, features = ["server-auto"] }
 rustls = { version = "0.23", default-features = false, features = ["tls12"] }
diff --git a/src/connector.rs b/src/connector.rs
index 96369d8..0ca5c5e 100644
--- a/src/connector.rs
+++ b/src/connector.rs
@@ -251,29 +251,23 @@ mod tests {
         assert_eq!(message, "unsupported scheme http");
     }
 
-    fn tls_config() -> rustls::ClientConfig {
-        #[cfg(feature = "rustls-platform-verifier")]
-        return rustls::ClientConfig::builder()
-            .with_platform_verifier()
-            .with_no_client_auth();
-
-        #[cfg(feature = "rustls-native-certs")]
-        return rustls::ClientConfig::builder()
-            .with_native_roots()
-            .unwrap()
-            .with_no_client_auth();
-
-        #[cfg(feature = "webpki-roots")]
-        return rustls::ClientConfig::builder()
-            .with_webpki_roots()
-            .with_no_client_auth();
-    }
-
     async fn connect(
         allow: Allow,
         scheme: Scheme,
     ) -> Result<MaybeHttpsStream<TokioIo<TcpStream>>, BoxError> {
-        let builder = HttpsConnectorBuilder::new().with_tls_config(tls_config());
+        let config_builder = rustls::ClientConfig::builder();
+        cfg_if::cfg_if! {
+            if #[cfg(feature = "rustls-platform-verifier")] {
+                let config_builder = config_builder.with_platform_verifier();
+            } else if #[cfg(feature = "rustls-native-certs")] {
+                let config_builder = config_builder.with_native_roots().unwrap();
+            } else if #[cfg(feature = "webpki-roots")] {
+                let config_builder = config_builder.with_webpki_roots();
+            }
+        }
+        let config = config_builder.with_no_client_auth();
+
+        let builder = HttpsConnectorBuilder::new().with_tls_config(config);
         let mut service = match allow {
             Allow::Https => builder.https_only(),
             Allow::Any => builder.https_or_http(),