Skip to content

Commit b311197

Browse files
zecakehpoljar
authored andcommitted
feat(sdk): Only allow TLS 1.2 or newer
As recommended by BCP 195. It shouldn't be a problem with rustls that only supports TLS 1.2 and 1.3, but with native-tls it depends on the implementation. Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
1 parent 1068d88 commit b311197

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

crates/matrix-sdk/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file.
1818
- The `MediaRetentionPolicy` can now trigger regular cleanups with its new
1919
`cleanup_frequency` setting.
2020
([#4603](https://github.com/matrix-org/matrix-rust-sdk/pull/4603))
21+
- The HTTP client only allows TLS 1.2 or newer, as recommended by BCP 195.
2122

2223
### Bug Fixes
2324

crates/matrix-sdk/src/http_client/native.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use bytes::Bytes;
2424
use bytesize::ByteSize;
2525
use eyeball::SharedObservable;
2626
use http::header::CONTENT_LENGTH;
27-
use reqwest::Certificate;
27+
use reqwest::{tls, Certificate};
2828
use ruma::api::{error::FromHttpResponseError, IncomingResponse, OutgoingRequest};
2929
use tracing::{debug, info, warn};
3030

@@ -148,8 +148,12 @@ impl HttpSettings {
148148
/// Build a client with the specified configuration.
149149
pub(crate) fn make_client(&self) -> Result<reqwest::Client, HttpError> {
150150
let user_agent = self.user_agent.clone().unwrap_or_else(|| "matrix-rust-sdk".to_owned());
151-
let mut http_client =
152-
reqwest::Client::builder().user_agent(user_agent).timeout(self.timeout);
151+
let mut http_client = reqwest::Client::builder()
152+
.user_agent(user_agent)
153+
.timeout(self.timeout)
154+
// As recommended by BCP 195.
155+
// See: https://datatracker.ietf.org/doc/bcp195/
156+
.min_tls_version(tls::Version::TLS_1_2);
153157

154158
if self.disable_ssl_verification {
155159
warn!("SSL verification disabled in the HTTP client!");

0 commit comments

Comments
 (0)