Skip to content

Commit f3e4474

Browse files
authored
Explicit list of TLS cipher suites (#2422)
Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
1 parent 2bb969f commit f3e4474

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repository = "https://github.com/awslabs/smithy-rs"
1111
rt-tokio = ["aws-smithy-async/rt-tokio"]
1212
test-util = ["aws-smithy-protocol-test", "serde/derive", "rustls", "hyper/server", "hyper/h2", "tokio/full"]
1313
native-tls = ["client-hyper", "hyper-tls", "rt-tokio"]
14-
rustls = ["client-hyper", "hyper-rustls", "rt-tokio", "lazy_static"]
14+
rustls = ["client-hyper", "hyper-rustls", "rt-tokio", "lazy_static", "dep:rustls"]
1515
client-hyper = ["hyper"]
1616
hyper-webpki-doctest-only = ["hyper-rustls/webpki-roots"]
1717

@@ -32,6 +32,7 @@ hyper = { version = "0.14.25", features = ["client", "http2", "http1", "tcp"], o
3232
# https://github.com/rust-lang/cargo/issues/1596
3333
hyper-rustls = { version = "0.23.0", optional = true, features = ["rustls-native-certs", "http2"] }
3434
hyper-tls = { version = "0.5.0", optional = true }
35+
rustls = { version = "0.20", optional = true }
3536
lazy_static = { version = "1", optional = true }
3637
pin-project-lite = "0.2.7"
3738
serde = { version = "1", features = ["derive"], optional = true }

rust-runtime/aws-smithy-client/src/conns.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,34 @@ pub type NativeTls = hyper_tls::HttpsConnector<hyper::client::HttpConnector>;
1919
/// A smithy connector that uses the `rustls` crate for TLS.
2020
pub type Rustls = crate::hyper_ext::Adapter<Https>;
2121

22+
#[cfg(feature = "rustls")]
23+
use hyper_rustls::ConfigBuilderExt;
24+
2225
// Creating a `with_native_roots` HTTP client takes 300ms on OS X. Cache this so that we
2326
// don't need to repeatedly incur that cost.
2427
#[cfg(feature = "rustls")]
2528
lazy_static::lazy_static! {
2629
static ref HTTPS_NATIVE_ROOTS: Https = {
2730
hyper_rustls::HttpsConnectorBuilder::new()
28-
.with_native_roots()
31+
.with_tls_config(
32+
rustls::ClientConfig::builder()
33+
.with_cipher_suites(&[
34+
// TLS1.3 suites
35+
rustls::cipher_suite::TLS13_AES_256_GCM_SHA384,
36+
rustls::cipher_suite::TLS13_AES_128_GCM_SHA256,
37+
// TLS1.2 suites
38+
rustls::cipher_suite::TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
39+
rustls::cipher_suite::TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
40+
rustls::cipher_suite::TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
41+
rustls::cipher_suite::TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
42+
rustls::cipher_suite::TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
43+
])
44+
.with_safe_default_kx_groups()
45+
.with_safe_default_protocol_versions()
46+
.expect("Error with the TLS configuration. Please file a bug report under https://github.com/awslabs/smithy-rs/issues.")
47+
.with_native_roots()
48+
.with_no_client_auth()
49+
)
2950
.https_or_http()
3051
.enable_http1()
3152
.enable_http2()

0 commit comments

Comments
 (0)