Skip to content

Commit d5c5f30

Browse files
committed
add secondary 'tls-rustls-webpki' and 'rustls-webpki' features that don't implicitly enable rustls-native-certs
1 parent 77e8062 commit d5c5f30

File tree

14 files changed

+36
-27
lines changed

14 files changed

+36
-27
lines changed

aws/rust-runtime/aws-config/Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ client-hyper = ["aws-smithy-runtime/connector-hyper-0-14-x"]
1717
credentials-process = ["tokio/process"]
1818
default = ["client-hyper", "rustls", "rt-tokio", "credentials-process", "sso"]
1919
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-runtime/rt-tokio", "tokio/rt"]
20-
rustls = ["aws-smithy-runtime/tls-rustls", "client-hyper"]
20+
rustls = ["aws-smithy-runtime/tls-rustls", "__rustls"]
21+
rustls-wepbki = ["aws-smithy-runtime/tls-rustls-webpki", "__rustls"]
2122
sso = ["dep:aws-sdk-sso", "dep:aws-sdk-ssooidc", "dep:ring", "dep:hex", "dep:zeroize", "aws-smithy-runtime-api/http-auth"]
2223
test-util = ["aws-runtime/test-util"]
2324

25+
# Enables common types used for rustls. Useless on its own.
26+
__rustls = ["aws-smithy-runtime/__rustls", "client-hyper"]
27+
2428
# deprecated: this feature does nothing
2529
allow-compilation = []
2630

aws/rust-runtime/aws-config/src/default_provider/credentials.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::meta::credentials::CredentialsProviderChain;
1414
use crate::meta::region::ProvideRegion;
1515
use crate::provider_config::ProviderConfig;
1616

17-
#[cfg(feature = "rustls")]
17+
#[cfg(feature = "__rustls")]
1818
/// Default Credentials Provider chain
1919
///
2020
/// The region from the default region provider will be used

aws/rust-runtime/aws-config/src/imds/client.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ pub(crate) mod test {
11041104
#[cfg_attr(windows, ignore)]
11051105
/// Verify that the end-to-end real client has a 1-second connect timeout
11061106
#[tokio::test]
1107-
#[cfg(feature = "rustls")]
1107+
#[cfg(feature = "__rustls")]
11081108
async fn one_second_connect_timeout() {
11091109
use crate::imds::client::ImdsError;
11101110
let client = Client::builder()

aws/rust-runtime/aws-config/src/imds/credentials.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ mod test {
417417
}
418418

419419
#[tokio::test]
420-
#[cfg(feature = "rustls")]
420+
#[cfg(feature = "__rustls")]
421421
async fn read_timeout_during_credentials_refresh_should_yield_last_retrieved_credentials() {
422422
let client = crate::imds::Client::builder()
423423
// 240.* can never be resolved
@@ -435,7 +435,7 @@ mod test {
435435
}
436436

437437
#[tokio::test]
438-
#[cfg(feature = "rustls")]
438+
#[cfg(feature = "__rustls")]
439439
async fn read_timeout_during_credentials_refresh_should_error_without_last_retrieved_credentials(
440440
) {
441441
let client = crate::imds::Client::builder()
@@ -457,7 +457,7 @@ mod test {
457457
// TODO(https://github.com/awslabs/aws-sdk-rust/issues/1117) This test is ignored on Windows because it uses Unix-style paths
458458
#[cfg_attr(windows, ignore)]
459459
#[tokio::test]
460-
#[cfg(feature = "rustls")]
460+
#[cfg(feature = "__rustls")]
461461
async fn external_timeout_during_credentials_refresh_should_yield_last_retrieved_credentials() {
462462
use aws_smithy_async::rt::sleep::AsyncSleep;
463463
let client = crate::imds::Client::builder()

aws/rust-runtime/aws-config/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ mod loader {
11601160
assert_eq!(Some(&app_name), conf.app_name());
11611161
}
11621162

1163-
#[cfg(feature = "rustls")]
1163+
#[cfg(feature = "__rustls")]
11641164
#[tokio::test]
11651165
async fn disable_default_credentials() {
11661166
let config = defaults(BehaviorVersion::latest())
@@ -1170,15 +1170,15 @@ mod loader {
11701170
assert!(config.credentials_provider().is_none());
11711171
}
11721172

1173-
#[cfg(feature = "rustls")]
1173+
#[cfg(feature = "__rustls")]
11741174
#[tokio::test]
11751175
async fn identity_cache_defaulted() {
11761176
let config = defaults(BehaviorVersion::latest()).load().await;
11771177

11781178
assert!(config.identity_cache().is_some());
11791179
}
11801180

1181-
#[cfg(feature = "rustls")]
1181+
#[cfg(feature = "__rustls")]
11821182
#[allow(deprecated)]
11831183
#[tokio::test]
11841184
async fn identity_cache_old_behavior_version() {

aws/rust-runtime/aws-config/src/meta/credentials/chain.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl CredentialsProviderChain {
7373
}
7474

7575
/// Add a fallback to the default provider chain
76-
#[cfg(feature = "rustls")]
76+
#[cfg(feature = "__rustls")]
7777
pub async fn or_default_provider(self) -> Self {
7878
self.or_else(
7979
"DefaultProviderChain",
@@ -82,7 +82,7 @@ impl CredentialsProviderChain {
8282
}
8383

8484
/// Creates a credential provider chain that starts with the default provider
85-
#[cfg(feature = "rustls")]
85+
#[cfg(feature = "__rustls")]
8686
pub async fn default_provider() -> Self {
8787
Self::first_try(
8888
"DefaultProviderChain",

aws/rust-runtime/aws-config/src/profile/credentials.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub(crate) mod repr;
9191
/// future::ProvideCredentials::new(self.load_credentials())
9292
/// }
9393
/// }
94-
/// # if cfg!(feature = "rustls") {
94+
/// # if cfg!(feature = "__rustls") {
9595
/// let provider = ProfileFileCredentialsProvider::builder()
9696
/// .with_custom_provider("Custom", MyCustomProvider)
9797
/// .build();
@@ -421,7 +421,7 @@ impl Builder {
421421
/// }
422422
/// }
423423
///
424-
/// # if cfg!(feature = "rustls") {
424+
/// # if cfg!(feature = "__rustls") {
425425
/// let provider = ProfileFileCredentialsProvider::builder()
426426
/// .with_custom_provider("Custom", MyCustomProvider)
427427
/// .build();

aws/rust-runtime/aws-config/src/provider_config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl ProviderConfig {
128128
///
129129
/// # Examples
130130
/// ```no_run
131-
/// # #[cfg(feature = "rustls")]
131+
/// # #[cfg(feature = "__rustls")]
132132
/// # fn example() {
133133
/// use aws_config::provider_config::ProviderConfig;
134134
/// use aws_sdk_sts::config::Region;

aws/rust-runtime/aws-config/src/test_case.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ where
321321
E: Error,
322322
{
323323
#[allow(unused)]
324-
#[cfg(all(feature = "client-hyper", feature = "rustls"))]
324+
#[cfg(all(feature = "client-hyper", feature = "__rustls"))]
325325
/// Record a test case from live (remote) HTTPS traffic
326326
///
327327
/// The `default_connector()` from the crate will be used

design/src/rfcs/rfc0002_http_versions.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ The `https()` method on the Builder constructs the actual Hyper client, and is d
9898
select the correct TLS implementation. For example:
9999

100100
```rust
101-
#[cfg(feature = "rustls")]
101+
#[cfg(feature = "__rustls")]
102102
pub fn https() -> Https {
103103
let https = hyper_rustls::HttpsConnector::with_native_roots();
104104
let client = hyper::Client::builder().build::<_, SdkBody>(https);
@@ -134,7 +134,7 @@ A default `make_connector` implementation would be provided that creates a Hyper
134134
Cargo feature flags. This might look something like this:
135135

136136
```rust
137-
#[cfg(feature = "rustls")]
137+
#[cfg(feature = "__rustls")]
138138
pub fn default_connector(reqs: &HttpRequirements) -> HyperAdapter {
139139
let https = hyper_rustls::HttpsConnector::with_native_roots();
140140
let mut builder = hyper::Client::builder();

design/src/rfcs/rfc0015_using_features_responsibly.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ As noted earlier in an excerpt from the Cargo book:
3535
> enabling a feature should not disable functionality, and it should usually be safe to enable any combination of features. A feature should not introduce a [SemVer-incompatible change].
3636
3737
```rust
38-
#[cfg(feature = "rustls")]
38+
#[cfg(feature = "__rustls")]
3939
impl<M, R> ClientBuilder<(), M, R> {
4040
/// Connect to the service over HTTPS using Rustls.
4141
pub fn tls_adapter(self) -> ClientBuilder<Adapter<crate::conns::Https>, M, R> {
@@ -59,7 +59,7 @@ When the example code above is compiled with both features enabled, compilation
5959
Here's an updated version of the example that fixes these issues:
6060

6161
```rust
62-
#[cfg(feature = "rustls")]
62+
#[cfg(feature = "__rustls")]
6363
impl<M, R> ClientBuilder<(), M, R> {
6464
/// Connect to the service over HTTPS using Rustls.
6565
pub fn rustls(self) -> ClientBuilder<Adapter<crate::conns::Https>, M, R> {

rust-runtime/aws-smithy-runtime/Cargo.toml

+7-2
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@ repository = "https://github.com/smithy-lang/smithy-rs"
1313
client = ["aws-smithy-runtime-api/client", "aws-smithy-types/http-body-1-x"]
1414
http-auth = ["aws-smithy-runtime-api/http-auth"]
1515
connector-hyper-0-14-x = ["dep:hyper-0-14", "hyper-0-14?/client", "hyper-0-14?/http2", "hyper-0-14?/http1", "hyper-0-14?/tcp", "hyper-0-14?/stream", "dep:h2"]
16-
tls-rustls = ["dep:hyper-rustls", "dep:rustls", "connector-hyper-0-14-x"]
16+
tls-rustls = ["hyper-rustls/native-tokio", "__rustls"]
17+
tls-rustls-webpki = ["hyper-rustls/webpki-tokio", "__rustls"]
1718
rt-tokio = ["tokio/rt"]
1819

1920
# Features for testing
2021
test-util = ["aws-smithy-runtime-api/test-util", "dep:aws-smithy-protocol-test", "dep:tracing-subscriber", "dep:serde", "dep:serde_json", "dep:indexmap"]
2122
wire-mock = ["test-util", "connector-hyper-0-14-x", "hyper-0-14?/server"]
2223

24+
# Enables common types used for rustls. Useless on its own.
25+
__rustls = ["dep:hyper-rustls", "dep:rustls", "connector-hyper-0-14-x"]
26+
27+
2328
[dependencies]
2429
aws-smithy-async = { path = "../aws-smithy-async" }
2530
aws-smithy-http = { path = "../aws-smithy-http" }
@@ -37,7 +42,7 @@ http-body-1x = { package = "http-body", version = "1" }
3742
# This avoids bringing `httparse` 1.9.0 and 1.9.1 through `hyper-0-14` that break unit tests of runtime crates
3843
httparse = "1.8.0"
3944
hyper-0-14 = { package = "hyper", version = "0.14.26", default-features = false, optional = true }
40-
hyper-rustls = { version = "0.24", features = ["rustls-native-certs", "http2"], optional = true }
45+
hyper-rustls = { version = "0.24", features = ["http1", "tls12", "logging", "aws-lc-rs", "http2"], default-features = false, optional = true }
4146
once_cell = "1.18.0"
4247
pin-project-lite = "0.2.7"
4348
pin-utils = "0.1.0"

rust-runtime/aws-smithy-runtime/src/client/http/hyper_014.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use std::sync::RwLock;
3434
use std::time::Duration;
3535
use tokio::io::{AsyncRead, AsyncWrite};
3636

37-
#[cfg(feature = "tls-rustls")]
37+
#[cfg(feature = "__rustls")]
3838
mod default_connector {
3939
use aws_smithy_async::rt::sleep::SharedAsyncSleep;
4040
use aws_smithy_runtime_api::client::http::HttpConnectorSettings;
@@ -98,7 +98,7 @@ pub fn default_connector(
9898
settings: &HttpConnectorSettings,
9999
sleep: Option<SharedAsyncSleep>,
100100
) -> Option<SharedHttpConnector> {
101-
#[cfg(feature = "tls-rustls")]
101+
#[cfg(feature = "__rustls")]
102102
{
103103
tracing::trace!(settings = ?settings, sleep = ?sleep, "creating a new default connector");
104104
let hyper = default_connector::base(settings, sleep).build_https();
@@ -113,7 +113,7 @@ pub fn default_connector(
113113

114114
/// Creates a hyper-backed HTTPS client from defaults depending on what cargo features are activated.
115115
pub fn default_client() -> Option<SharedHttpClient> {
116-
#[cfg(feature = "tls-rustls")]
116+
#[cfg(feature = "__rustls")]
117117
{
118118
tracing::trace!("creating a new default hyper 0.14.x client");
119119
Some(HyperClientBuilder::new().build_https())
@@ -202,7 +202,7 @@ impl HyperConnectorBuilder {
202202
}
203203

204204
/// Create a [`HyperConnector`] with the default rustls HTTPS implementation.
205-
#[cfg(feature = "tls-rustls")]
205+
#[cfg(feature = "__rustls")]
206206
pub fn build_https(self) -> HyperConnector {
207207
self.build(default_connector::https())
208208
}
@@ -580,7 +580,7 @@ impl HyperClientBuilder {
580580
///
581581
/// The trusted certificates will be loaded later when this becomes the selected
582582
/// HTTP client for a Smithy client.
583-
#[cfg(feature = "tls-rustls")]
583+
#[cfg(feature = "__rustls")]
584584
pub fn build_https(self) -> SharedHttpClient {
585585
self.build_with_fn(default_connector::https)
586586
}

rust-runtime/aws-smithy-runtime/src/client/http/test_util/dvr/record.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub struct RecordingClient {
7474
pub(crate) inner: SharedHttpConnector,
7575
}
7676

77-
#[cfg(feature = "tls-rustls")]
77+
#[cfg(feature = "__rustls")]
7878
impl RecordingClient {
7979
/// Construct a recording connection wrapping a default HTTPS implementation without any timeouts.
8080
pub fn https() -> Self {

0 commit comments

Comments
 (0)