From 87ff5d9bf4af768908e39793563e6aa29f2ced41 Mon Sep 17 00:00:00 2001 From: Eric Seppanen <109770420+eric-seppanen@users.noreply.github.com> Date: Mon, 21 Aug 2023 11:53:43 -0700 Subject: [PATCH] improve error message if incompabitle Identity with selected backend (#1852) If ClientBuilder::build encounters a TlsBackend::Default, and cfg(native-tls) is not enabled, it doesn't know how to load the client certificate. Rather than silently ignore the attempt to use a client identity, return an error. * ClientBuilder: fix build when rustls and native-tls are both enabled --- src/async_impl/client.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/async_impl/client.rs b/src/async_impl/client.rs index a6d508032..44cff22ac 100644 --- a/src/async_impl/client.rs +++ b/src/async_impl/client.rs @@ -372,6 +372,13 @@ impl ClientBuilder { id.add_to_native_tls(&mut tls)?; } } + #[cfg(all(feature = "__rustls", not(feature = "native-tls")))] + { + // Default backend + rustls Identity doesn't work. + if let Some(_id) = config.identity { + return Err(crate::error::builder("incompatible TLS identity type")); + } + } if let Some(min_tls_version) = config.min_tls_version { let protocol = min_tls_version.to_native_tls().ok_or_else(|| {