diff --git a/deny.toml b/deny.toml index a7a99e607..5a0b5d85d 100644 --- a/deny.toml +++ b/deny.toml @@ -31,6 +31,8 @@ allow = [ # Pulled in via aws_lc_rs when using rustls-tls and aws-lc-rs features # https://openssl-library.org/source/license/index.html "OpenSSL", + # Pulled in via hyper-rustls when using the webpki-roots feature + "MPL-2.0", ] exceptions = [ diff --git a/kube-client/Cargo.toml b/kube-client/Cargo.toml index 69ce0a222..c7c262933 100644 --- a/kube-client/Cargo.toml +++ b/kube-client/Cargo.toml @@ -14,6 +14,7 @@ categories = ["web-programming::http-client", "network-programming", "api-bindin [features] default = ["client"] rustls-tls = ["rustls", "rustls-pemfile", "hyper-rustls", "hyper-http-proxy?/rustls-tls-native-roots"] +webpki-roots = ["hyper-rustls/webpki-roots"] aws-lc-rs = ["rustls?/aws-lc-rs"] openssl-tls = ["openssl", "hyper-openssl"] ws = ["client", "tokio-tungstenite", "rand", "kube-core/ws", "tokio/macros"] diff --git a/kube-client/src/client/tls.rs b/kube-client/src/client/tls.rs index 136a9bfa0..25bdb737e 100644 --- a/kube-client/src/client/tls.rs +++ b/kube-client/src/client/tls.rs @@ -55,9 +55,18 @@ pub mod rustls_tls { let config_builder = if let Some(certs) = root_certs { ClientConfig::builder().with_root_certificates(root_store(certs)?) } else { - ClientConfig::builder() - .with_native_roots() - .map_err(Error::NoValidNativeRootCA)? + #[cfg(feature = "webpki-roots")] + { + // Use WebPKI roots. + ClientConfig::builder().with_webpki_roots() + } + #[cfg(not(feature = "webpki-roots"))] + { + // Use native roots. This will panic on Android and iOS. + ClientConfig::builder() + .with_native_roots() + .map_err(Error::NoValidNativeRootCA)? + } }; let mut client_config = if let Some((chain, pkey)) = identity_pem.map(client_auth).transpose()? { diff --git a/kube/Cargo.toml b/kube/Cargo.toml index ef579effd..d56d470eb 100644 --- a/kube/Cargo.toml +++ b/kube/Cargo.toml @@ -37,6 +37,7 @@ unstable-runtime = ["kube-runtime/unstable-runtime", "runtime"] unstable-client = ["kube-client/unstable-client", "client"] socks5 = ["kube-client/socks5", "client"] http-proxy = ["kube-client/http-proxy", "client"] +webpki-roots = ["kube-client/webpki-roots", "client"] [package.metadata.docs.rs] features = ["client", "rustls-tls", "openssl-tls", "derive", "ws", "oauth", "jsonpatch", "admission", "runtime", "k8s-openapi/latest", "unstable-runtime", "socks5", "http-proxy"]