forked from smithy-lang/smithy-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add FIPS support to Hyper 1.0 Client (smithy-lang#3539)
## Description This does several things: 1. Upgrade to RusTLS 0.23 which enables FIPS support 2. Add smoke test of the clients. This revealed a bug where https URLs were not supported. This is technically a breaking change because I added `non_exhaustive` to the CryptoMode enum. <!--- Describe your changes in detail --> ## Testing New integration tests. I expect this to fail in CI since I'll need to update the build image to match. ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [x] I have updated `CHANGELOG.next.toml` if I made changes to the smithy-rs codegen or runtime crates - [x] I have updated `CHANGELOG.next.toml` if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
- Loading branch information
Showing
10 changed files
with
168 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "aws-smithy-experimental" | ||
version = "0.1.0" | ||
version = "0.1.1" | ||
authors = ["AWS Rust SDK Team <[email protected]>"] | ||
description = "Experiments for the smithy-rs ecosystem" | ||
edition = "2021" | ||
|
@@ -9,7 +9,8 @@ repository = "https://github.com/smithy-lang/smithy-rs" | |
|
||
[features] | ||
crypto-ring = ["rustls/ring"] | ||
crypto-aws-lc = ["rustls/aws_lc_rs", "dep:fs_extra"] | ||
crypto-aws-lc = ["rustls/aws_lc_rs"] | ||
crypto-aws-lc-fips = ["rustls/fips"] | ||
|
||
[dependencies] | ||
aws-smithy-types = { path = "../aws-smithy-types", features = ["http-body-1-x"] } | ||
|
@@ -20,13 +21,12 @@ pin-project-lite = "0.2.13" | |
hyper-util = "0.1.3" | ||
http = "1" | ||
tokio = "1" | ||
hyper-rustls = { version = "0.26", features = ["http2", "http1"] } | ||
rustls = { version = "0.22.2", default-features = false } | ||
hyper-rustls = { version = "0.27", features = ["http2", "http1", "native-tokio", "tls12"], default-features = false } | ||
rustls = { version = "0.23", default-features = false } | ||
h2 = "0.4" | ||
once_cell = "1.18.0" | ||
tracing = "0.1.40" | ||
tower = "0.4.1" | ||
fs_extra = { version = "1.3.0", optional = true } # hack for cargo-minimal-versions | ||
|
||
[dev-dependencies] | ||
aws-smithy-async = { path = "../aws-smithy-async", features = ["rt-tokio", "test-util"] } | ||
|
@@ -40,7 +40,7 @@ doc-scrape-examples = true | |
|
||
[[example]] | ||
name = "client-aws-lc" | ||
required-features = ["crypto-aws-lc"] | ||
required-features = ["crypto-aws-lc", "crypto-aws-lc-fips"] | ||
doc-scrape-examples = true | ||
|
||
[[example]] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
rust-runtime/aws-smithy-experimental/tests/smoke_test_clients.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
use aws_smithy_async::time::SystemTimeSource; | ||
use aws_smithy_experimental::hyper_1_0::{CryptoMode, HyperClientBuilder}; | ||
use aws_smithy_runtime_api::client::dns::{DnsFuture, ResolveDns, ResolveDnsError}; | ||
use aws_smithy_runtime_api::client::http::{HttpClient, HttpConnector, HttpConnectorSettings}; | ||
use aws_smithy_runtime_api::client::orchestrator::HttpRequest; | ||
use aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder; | ||
use hyper_util::client::legacy::connect::dns::{GaiResolver, Name}; | ||
use std::error::Error; | ||
use std::str::FromStr; | ||
use std::sync::Arc; | ||
use tower::Service; | ||
|
||
#[cfg(feature = "crypto-ring")] | ||
#[tokio::test] | ||
async fn ring_client() { | ||
let client = HyperClientBuilder::new() | ||
.crypto_mode(CryptoMode::Ring) | ||
.build_https(); | ||
smoke_test_client(&client).await.unwrap(); | ||
} | ||
|
||
#[cfg(feature = "crypto-aws-lc-fips")] | ||
#[tokio::test] | ||
async fn aws_lc_fips_client() { | ||
let client = HyperClientBuilder::new() | ||
.crypto_mode(CryptoMode::AwsLcFips) | ||
.build_https(); | ||
smoke_test_client(&client).await.unwrap(); | ||
} | ||
|
||
#[cfg(feature = "crypto-aws-lc")] | ||
#[tokio::test] | ||
async fn aws_lc_client() { | ||
let client = HyperClientBuilder::new() | ||
.crypto_mode(CryptoMode::AwsLc) | ||
.build_https(); | ||
smoke_test_client(&client).await.unwrap(); | ||
} | ||
|
||
#[cfg(feature = "crypto-ring")] | ||
#[tokio::test] | ||
async fn custom_dns_client() { | ||
use std::sync::atomic::{AtomicUsize, Ordering}; | ||
#[derive(Debug, Clone)] | ||
struct PassThroughResolver { | ||
inner: GaiResolver, | ||
count: Arc<AtomicUsize>, | ||
} | ||
impl ResolveDns for PassThroughResolver { | ||
fn resolve_dns<'a>(&'a self, _name: &'a str) -> DnsFuture<'a> { | ||
let mut inner = self.inner.clone(); | ||
let name = Name::from_str(_name).unwrap(); | ||
let count = self.count.clone(); | ||
DnsFuture::new(async move { | ||
count.fetch_add(1, Ordering::Relaxed); | ||
let result = inner | ||
.call(name) | ||
.await | ||
.map_err(|err| ResolveDnsError::new(err))?; | ||
Ok(result.map(|addr| addr.ip()).collect::<Vec<_>>()) | ||
}) | ||
} | ||
} | ||
let resolver = PassThroughResolver { | ||
inner: GaiResolver::new(), | ||
count: Default::default(), | ||
}; | ||
let client = HyperClientBuilder::new() | ||
.crypto_mode(CryptoMode::Ring) | ||
.build_with_resolver(resolver.clone()); | ||
smoke_test_client(&client).await.unwrap(); | ||
assert_eq!(resolver.count.load(Ordering::Relaxed), 1); | ||
} | ||
|
||
async fn smoke_test_client(client: &dyn HttpClient) -> Result<(), Box<dyn Error>> { | ||
let connector_settings = HttpConnectorSettings::builder().build(); | ||
let runtime_components = RuntimeComponentsBuilder::for_tests() | ||
.with_time_source(Some(SystemTimeSource::new())) | ||
.build() | ||
.unwrap(); | ||
let connector = client.http_connector(&connector_settings, &runtime_components); | ||
let _response = connector | ||
.call(HttpRequest::get("https://amazon.com").unwrap()) | ||
.await?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters