で最小 TLS バージョンを適用する AWS SDK for Rust - AWS SDK for Rust

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

で最小 TLS バージョンを適用する AWS SDK for Rust

は TLS AWS SDK for Rust を使用して、 AWS サービスと通信する際のセキュリティを強化します。SDK は、デフォルトで 1.2 の最小 TLS バージョンを適用します。デフォルトでは、SDK はクライアントアプリケーションとサービスの両方で利用可能な TLS の最高バージョンもネゴシエートします。たとえば、SDK は TLS 1.3 をネゴシエートできる場合があります。

SDK が使用する TCP コネクタを手動で設定することで、特定の TLS バージョンをアプリケーションに適用できます。これを説明するために、次の例は TLS 1.3 を適用する方法を示しています。

注記

一部の AWS サービスはまだ TLS 1.3 をサポートしていないため、このバージョンを適用すると SDK の相互運用性に影響する可能性があります。本番デプロイの前に、各サービスでこの設定をテストすることをお勧めします。

pub async fn connect_via_tls_13() -> Result<(), Error> { println!("Attempting to connect to KMS using TLS 1.3: "); // Let webpki load the Mozilla root certificates. let mut root_store = RootCertStore::empty(); root_store.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| { rustls::OwnedTrustAnchor::from_subject_spki_name_constraints( ta.subject, ta.spki, ta.name_constraints, ) })); // The .with_protocol_versions call is where we set TLS1.3. You can add rustls::version::TLS12 or replace them both with rustls::ALL_VERSIONS let config = rustls::ClientConfig::builder() .with_safe_default_cipher_suites() .with_safe_default_kx_groups() .with_protocol_versions(&[&rustls::version::TLS13]) .expect("It looks like your system doesn't support TLS1.3") .with_root_certificates(root_store) .with_no_client_auth(); // Finish setup of the rustls connector. let rustls_connector = hyper_rustls::HttpsConnectorBuilder::new() .with_tls_config(config) .https_only() .enable_http1() .enable_http2() .build(); // See https://github.com/awslabs/smithy-rs/discussions/3022 for the HyperClientBuilder let http_client = HyperClientBuilder::new().build(rustls_connector); let shared_conf = aws_config::defaults(BehaviorVersion::latest()) .http_client(http_client) .load() .await; let kms_client = aws_sdk_kms::Client::new(&shared_conf); let response = kms_client.list_keys().send().await?; println!("{:?}", response); Ok(()) }