Skip to content

Commit

Permalink
Add a rustls-webpki feature, to use webpki-roots
Browse files Browse the repository at this point in the history
When rusoto creates a hyper-rustls HttpsConnector, it currently calls
HttpsConnector::with_native_roots directly, which hardcodes the use of
rustls-native-certs. For applications that want to deploy
as self-contained minimal binaries and not depend on a system
certificate store, add a rustls-webpki feature, which uses webpki-roots
instead.
  • Loading branch information
joshtriplett authored and benesch committed Jun 29, 2021
1 parent 6a2d350 commit 806a7e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions rusoto/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ encoding = ["flate2"]
nightly-testing = ["rusoto_credential/nightly-testing"]
native-tls = ["hyper-tls"]
rustls = ["hyper-rustls"]
rustls-webpki = ["hyper-rustls/webpki-tokio"]
unstable = []

[package.metadata.docs.rs]
Expand Down
10 changes: 8 additions & 2 deletions rusoto/core/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,12 @@ impl HttpClient {
#[cfg(feature = "native-tls")]
let connector = HttpsConnector::new();

#[cfg(feature = "rustls")]
#[cfg(all(feature = "rustls", not(feature = "rustls-webpki")))]
let connector = HttpsConnector::with_native_roots();

#[cfg(feature = "rustls-webpki")]
let connector = HttpsConnector::with_webpki_roots();

Ok(Self::from_connector(connector))
}

Expand All @@ -234,9 +237,12 @@ impl HttpClient {
#[cfg(feature = "native-tls")]
let connector = HttpsConnector::new();

#[cfg(feature = "rustls")]
#[cfg(all(feature = "rustls", not(feature = "rustls-webpki")))]
let connector = HttpsConnector::with_native_roots();

#[cfg(feature = "rustls-webpki")]
let connector = HttpsConnector::with_webpki_roots();

Ok(Self::from_connector_with_config(connector, config))
}

Expand Down

0 comments on commit 806a7e1

Please sign in to comment.