Skip to content

Commit b1c034d

Browse files
committed
bitreq: deps: bump rustls to version 0.23
1 parent 0b8bea9 commit b1c034d

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

bitreq/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ serde_json = { version = "1.0.0", default-features = false, features = ["std"],
2121
base64 = { version = "0.22", default-features = false, features = ["alloc"], optional = true }
2222

2323
# For rustls-based TLS:
24-
rustls = { version = "0.21.1", default-features = false, optional = true }
24+
rustls = { version = "0.23.37", default-features = false, optional = true }
2525
rustls-native-certs = { version = "0.6.1", default-features = false, optional = true }
2626
webpki-roots = { version = "0.25.2", default-features = false, optional = true }
2727
rustls-webpki = { version = "0.101.0", default-features = false, optional = true }
@@ -31,7 +31,7 @@ native-tls = { version = "0.2", default-features = false, optional = true }
3131

3232
# For the async feature:
3333
tokio = { version = "1.0", default-features = false, features = ["rt", "net", "io-util", "time", "sync"], optional = true }
34-
tokio-rustls = { version = "0.24", default-features = false, optional = true }
34+
tokio-rustls = { version = "0.26", default-features = false, optional = true }
3535
tokio-native-tls = { version = "0.3", default-features = false, optional = true }
3636

3737
log = { version = "0.4.0", default-features = false, optional = true }

bitreq/src/connection/rustls_stream.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ use std::sync::OnceLock;
1212
#[cfg(all(feature = "native-tls", not(feature = "rustls")))]
1313
use native_tls::{HandshakeError, TlsConnector, TlsStream};
1414
#[cfg(feature = "rustls")]
15-
use rustls::{self, ClientConfig, ClientConnection, RootCertStore, ServerName, StreamOwned};
15+
use rustls::{
16+
self,
17+
pki_types::{ServerName, TrustAnchor},
18+
ClientConfig, ClientConnection, RootCertStore, StreamOwned,
19+
};
1620
#[cfg(all(feature = "native-tls", not(feature = "rustls"), feature = "tokio-native-tls"))]
1721
use tokio_native_tls::TlsConnector as AsyncTlsConnector;
1822
#[cfg(feature = "tokio-rustls")]
@@ -47,19 +51,15 @@ fn build_client_config() -> Arc<ClientConfig> {
4751
}
4852

4953
#[cfg(feature = "rustls-webpki")]
50-
#[allow(deprecated)] // Need to use add_server_trust_anchors to compile with rustls 0.21.1
51-
root_certificates.add_server_trust_anchors(TLS_SERVER_ROOTS.iter().map(|ta| {
52-
rustls::OwnedTrustAnchor::from_subject_spki_name_constraints(
53-
ta.subject,
54-
ta.spki,
55-
ta.name_constraints,
56-
)
54+
#[allow(deprecated)]
55+
root_certificates.extend(TLS_SERVER_ROOTS.iter().map(|ta| TrustAnchor {
56+
subject: ta.subject.into(),
57+
subject_public_key_info: ta.spki.into(),
58+
name_constraints: ta.name_constraints.map(Into::into),
5759
}));
5860

59-
let config = ClientConfig::builder()
60-
.with_safe_defaults()
61-
.with_root_certificates(root_certificates)
62-
.with_no_client_auth();
61+
let config =
62+
ClientConfig::builder().with_root_certificates(root_certificates).with_no_client_auth();
6363
Arc::new(config)
6464
}
6565

@@ -71,8 +71,9 @@ pub(super) fn wrap_stream(tcp: TcpStream, host: &str) -> Result<SecuredStream, E
7171
Ok(result) => result,
7272
Err(err) => return Err(Error::IoError(io::Error::new(io::ErrorKind::Other, err))),
7373
};
74-
let sess = ClientConnection::new(CONFIG.get_or_init(build_client_config).clone(), dns_name)
75-
.map_err(Error::RustlsCreateConnection)?;
74+
let sess =
75+
ClientConnection::new(CONFIG.get_or_init(build_client_config).clone(), dns_name.to_owned())
76+
.map_err(Error::RustlsCreateConnection)?;
7677

7778
#[cfg(feature = "log")]
7879
log::trace!("Establishing TLS session to {host}.");
@@ -101,7 +102,7 @@ pub(super) async fn wrap_async_stream(
101102
#[cfg(feature = "log")]
102103
log::trace!("Establishing TLS session to {host}.");
103104

104-
let tls = connector.connect(dns_name, tcp).await.map_err(Error::IoError)?;
105+
let tls = connector.connect(dns_name.to_owned(), tcp).await.map_err(Error::IoError)?;
105106

106107
Ok(AsyncHttpStream::Secured(Box::new(tls)))
107108
}

0 commit comments

Comments
 (0)