-
Hello! I was wondering if I could get another set of eyes on what I could have misconfigured when trying to interact with the SDK. I'm currently just trying to list buckets out in my AWS environment using the Rust SDK and I'm running into issues with "Connection Reset by peer". I'm having zero issues running these in Python, Golang, or even directly from the AWS CLI (via `DispatchFailure(DispatchFailure { source: ConnectorError { kind: Other(None), source: hyper_util::client::legacy::Error(Connect, Custom { kind: Other, error: Os { code: 54, kind: ConnectionReset, message: "Connection reset by peer" } }), connection: Unknown } }) My code is pretty much the following: #[tokio::main]
async fn main() {
let sdk_config = aws_config::load_from_env().await;
let s3_client = aws_sdk_s3::Client::new(&sdk_config);
let result = s3_client.list_buckets().send().await.unwrap();
println!("Buckets:");
for bucket in result.buckets.unwrap_or_default() {
println!(" {}", bucket.name.unwrap_or_default());
} It's worth noting I am working at a company behind a proxy and thought it might have to do with SSL. I have a fn tls_context_from_pem(filename: &str) -> tls::TlsContext {
let pem_contents = fs::read(filename).unwrap();
let trust_store = tls::TrustStore::empty().with_pem_certificate(pem_contents.as_slice());
tls::TlsContext::builder()
.with_trust_store(trust_store)
.build()
.expect("valid TLS config")
}
#[tokio::main]
async fn main() {
let http_client = Builder::new()
.tls_provider(tls::Provider::Rustls(CryptoMode::AwsLc))
.tls_context(tls_context_from_pem("/path/to/cert-file.crt"))
.build_https();
let sdk_config = aws_config::defaults(aws_config::BehaviorVersion::latest())
.http_client(http_client)
.load()
.await;
let s3_client = aws_sdk_s3::Client::new(&sdk_config);
match s3_client.list_buckets().send().await {
Ok(res) => {
println!("Your buckets: {:?}", res.buckets())
}
Err(err) => {
println!("an error occurred when trying to list buckets: {}", err)
}
}
} Yet I'm still running into the same error (I even attempted to convert the Other info: Using an M1 Mac running Sequoia Dependencies in this project [dependencies]
aws-config = { version = "1.6.1", features = ["behavior-version-latest"] }
aws-sdk-s3 = { version = "1.82.0", features = ["behavior-version-latest"] }
aws-smithy-http-client = { version = "1.0.1", features = ["rustls-aws-lc"] }
tokio = { version = "1.44.2", features = ["full"] } Any help would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
This can be closed turns out this had nothing to do with the cert file not being correctly recognized and more to do with the lack of https_proxy support. I was able to resolve my issue by creating a custom http connector |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
This can be closed turns out this had nothing to do with the cert file not being correctly recognized and more to do with the lack of https_proxy support.
I was able to resolve my issue by creating a custom http connector