Skip to content

Commit

Permalink
add a webpki-roots feature to optionally use WebPKI roots on rustls
Browse files Browse the repository at this point in the history
Signed-off-by: Elias Wilken <[email protected]>
  • Loading branch information
ewilken committed Oct 26, 2023
1 parent c3fbe25 commit 1e5fd48
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions kube-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ edition = "2021"
[features]
default = ["client"]
rustls-tls = ["rustls", "rustls-pemfile", "hyper-rustls"]
webpki-roots = ["hyper-rustls/webpki-roots"]
openssl-tls = ["openssl", "hyper-openssl"]
ws = ["client", "tokio-tungstenite", "rand", "kube-core/ws", "tokio/macros"]
oauth = ["client", "tame-oauth"]
Expand Down
12 changes: 11 additions & 1 deletion kube-client/src/client/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,17 @@ pub mod rustls_tls {
.with_safe_defaults()
.with_root_certificates(root_store(certs)?)
} else {
ClientConfig::builder().with_safe_defaults().with_native_roots()
#[cfg(feature = "webpki-roots")]
{
// Use WebPKI roots.
ClientConfig::builder().with_safe_defaults().with_webpki_roots()
}

#[cfg(not(feature = "webpki-roots"))]
{
// Use native roots. This will panic on Android and iOS.
ClientConfig::builder().with_safe_defaults().with_native_roots()
}
};

let mut client_config = if let Some((chain, pkey)) = identity_pem.map(client_auth).transpose()? {
Expand Down
1 change: 1 addition & 0 deletions kube/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ admission = ["kube-core/admission"]
derive = ["kube-derive", "kube-core/schema"]
runtime = ["kube-runtime"]
unstable-runtime = ["kube-runtime/unstable-runtime"]
webpki-roots = ["kube-client/webpki-roots"]

[package.metadata.docs.rs]
features = ["client", "rustls-tls", "openssl-tls", "derive", "ws", "oauth", "jsonpatch", "admission", "runtime", "k8s-openapi/latest", "unstable-runtime"]
Expand Down

0 comments on commit 1e5fd48

Please sign in to comment.