- 
                Notifications
    
You must be signed in to change notification settings  - Fork 265
 
Description
Describe the bug
aws-sdk-rust includes an example of how to configure hyper-rustls to use webpki-roots and TLS 1.3, in examples/tls/src/lib.rs.
However, this example has two separate versions of hyper-rustls involved (0.23.0 and 0.22.1), and while hyper-rustls 0.23.0 is configured to use webpki-roots, something in aws-sdk-rust is still attempting to initialize hyper-rustls 0.22.1, which is failing with this error:
thread 'main' panicked at 'no CA certificates found', /home/josh/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-rustls-0.22.1/src/connector.rs:45:13
(The easiest way to test this is to build a static binary using the x86_64-unknown-linux-musl target and run it in an otherwise empty chroot.)
Expected Behavior
I'd like to use aws-sdk-rust with only webpki-roots, in a standalone static binary that has no system certificate store.
Current Behavior
thread 'main' panicked at 'no CA certificates found', /home/josh/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-rustls-0.22.1/src/connector.rs:45:13
Reproduction Steps
Here's a cut down version of the example (skipping the TLS 1.3 bits):
Cargo.toml
[package]
name = "awstest"
version = "0.1.0"
edition = "2021"
[dependencies]
anyhow = "1.0.58"
async-std = { version = "1.12.0", features = ["tokio1", "attributes"] }
aws-config = { version = "0.15.0", default-features = false, features = ["rustls"] }
aws-sdk-sts = { version = "0.15.0", default-features = false }
aws-smithy-client = { version = "0.45.0", default-features = false }
hyper-rustls = { version = "0.23.0", default-features = false, features = ["http1", "http2", "tls12", "webpki-roots", "webpki-tokio"] }(aws-config needs rustls enabled due to an unrelated bug. And the hyper-rustls dependency is coming in via aws-smithy-client: despite default-features = false, there's an indirect dependency on aws-smithy-client's default features via aws-types, among other things.)
src/main.rs
#[async_std::main]
async fn main() -> anyhow::Result<()> {
    let https_connector = hyper_rustls::HttpsConnectorBuilder::new()
        .with_webpki_roots()
        .https_only()
        .enable_http1()
        .enable_http2()
        .build();
    let provider_config = aws_config::provider_config::ProviderConfig::default()
        .with_tcp_connector(https_connector.clone())
        .load_default_region()
        .await;
    let aws_sdk_config = aws_config::from_env()
        .configure(provider_config)
        .load()
        .await;
    let sts = aws_sdk_sts::Client::from_conf_conn(
        aws_sdk_sts::Config::from(&aws_sdk_config),
        aws_smithy_client::hyper_ext::Adapter::builder().build(https_connector),
    );
    let identity = sts.get_caller_identity().send().await?;
    dbg!(identity);
    Ok(())
}Some debug prints suggest that the issue happens when trying to create aws_sdk_config. The example in "possible solution" gives a workaround.
Possible Solution
Alternate example that does work:
src/main.rs
#[async_std::main]
async fn main() -> anyhow::Result<()> {
    let https_connector = hyper_rustls::HttpsConnectorBuilder::new()
        .with_webpki_roots()
        .https_only()
        .enable_http1()
        .enable_http2()
        .build();
    let provider_config = aws_config::provider_config::ProviderConfig::default()
        .with_tcp_connector(https_connector.clone())
        .load_default_region()
        .await;
    let adapter = aws_smithy_client::hyper_ext::Adapter::builder().build(https_connector);
    let dyn_connector = aws_smithy_client::erase::DynConnector::new(adapter.clone());
    let aws_sdk_config = aws_config::from_env()
        .http_connector(aws_smithy_client::http_connector::HttpConnector::Prebuilt(Some(dyn_connector)))
        .configure(provider_config)
        .load()
        .await;
    let sts = aws_sdk_sts::Client::from_conf_conn(
        aws_sdk_sts::Config::from(&aws_sdk_config),
        adapter,
    );
    let identity = sts.get_caller_identity().send().await?;
    dbg!(identity);
    Ok(())
}Additional Information/Context
No response
Version
├── aws-config v0.15.0
│   ├── aws-http v0.15.0
│   │   ├── aws-smithy-http v0.45.0
│   │   │   ├── aws-smithy-types v0.45.0
│   │   ├── aws-smithy-types v0.45.0 (*)
│   │   ├── aws-types v0.15.0
│   │   │   ├── aws-smithy-async v0.45.0
│   │   │   ├── aws-smithy-client v0.45.0
│   │   │   │   ├── aws-smithy-async v0.45.0 (*)
│   │   │   │   ├── aws-smithy-http v0.45.0 (*)
│   │   │   │   ├── aws-smithy-http-tower v0.45.0
│   │   │   │   │   ├── aws-smithy-http v0.45.0 (*)
│   │   │   │   ├── aws-smithy-types v0.45.0 (*)
│   │   │   ├── aws-smithy-http v0.45.0 (*)
│   │   │   ├── aws-smithy-types v0.45.0 (*)
│   ├── aws-sdk-sso v0.15.0
│   │   ├── aws-endpoint v0.15.0
│   │   │   ├── aws-smithy-http v0.45.0 (*)
│   │   │   ├── aws-types v0.15.0 (*)
│   │   ├── aws-http v0.15.0 (*)
│   │   ├── aws-sig-auth v0.15.0
│   │   │   ├── aws-sigv4 v0.15.0
│   │   │   │   ├── aws-smithy-http v0.45.0 (*)
│   │   │   ├── aws-smithy-http v0.45.0 (*)
│   │   │   ├── aws-types v0.15.0 (*)
│   │   ├── aws-smithy-async v0.45.0 (*)
│   │   ├── aws-smithy-client v0.45.0 (*)
│   │   ├── aws-smithy-http v0.45.0 (*)
│   │   ├── aws-smithy-http-tower v0.45.0 (*)
│   │   ├── aws-smithy-json v0.45.0
│   │   │   └── aws-smithy-types v0.45.0 (*)
│   │   ├── aws-smithy-types v0.45.0 (*)
│   │   ├── aws-types v0.15.0 (*)
│   ├── aws-sdk-sts v0.15.0
│   │   ├── aws-endpoint v0.15.0 (*)
│   │   ├── aws-http v0.15.0 (*)
│   │   ├── aws-sig-auth v0.15.0 (*)
│   │   ├── aws-smithy-async v0.45.0 (*)
│   │   ├── aws-smithy-client v0.45.0 (*)
│   │   ├── aws-smithy-http v0.45.0 (*)
│   │   ├── aws-smithy-http-tower v0.45.0 (*)
│   │   ├── aws-smithy-query v0.45.0
│   │   │   ├── aws-smithy-types v0.45.0 (*)
│   │   ├── aws-smithy-types v0.45.0 (*)
│   │   ├── aws-smithy-xml v0.45.0
│   │   ├── aws-types v0.15.0 (*)
│   ├── aws-smithy-async v0.45.0 (*)
│   ├── aws-smithy-client v0.45.0 (*)
│   ├── aws-smithy-http v0.45.0 (*)
│   ├── aws-smithy-http-tower v0.45.0 (*)
│   ├── aws-smithy-json v0.45.0 (*)
│   ├── aws-smithy-types v0.45.0 (*)
│   ├── aws-types v0.15.0 (*)
├── aws-sdk-sts v0.15.0 (*)
├── aws-smithy-client v0.45.0 (*)
Environment details (OS name and version, etc.)
Debian, latest sid
Logs
No response