Skip to content

Commit b7af2e5

Browse files
RUST-1220 Bump outdated dependencies (#596)
1 parent beee61e commit b7af2e5

File tree

8 files changed

+88
-71
lines changed

8 files changed

+88
-71
lines changed

.evergreen/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,9 +1283,9 @@ axes:
12831283
- id: "extra-rust-versions"
12841284
values:
12851285
- id: "min"
1286-
display_name: "1.49 (minimum supported version)"
1286+
display_name: "1.51 (minimum supported version)"
12871287
variables:
1288-
RUST_VERSION: "1.49.0"
1288+
RUST_VERSION: "1.51.0"
12891289
- id: "nightly"
12901290
display_name: "nightly"
12911291
variables:

Cargo.toml

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,43 +57,42 @@ futures-io = "0.3.14"
5757
futures-util = { version = "0.3.14", features = ["io"] }
5858
futures-executor = "0.3.14"
5959
hex = "0.4.0"
60-
hmac = "0.11"
60+
hmac = "0.12.1"
6161
lazy_static = "1.4.0"
62-
md-5 = "0.9.1"
62+
md-5 = "0.10.1"
6363
openssl = { version = "0.10.38", optional = true }
6464
openssl-probe = { version = "0.1.5", optional = true }
6565
os_info = { version = "3.0.1", default-features = false }
6666
percent-encoding = "2.0.0"
6767
rand = { version = "0.8.3", features = ["small_rng"] }
68-
rustls-pemfile = "0.2.1"
68+
rustls-pemfile = "0.3.0"
6969
serde_with = "1.3.1"
70-
sha-1 = "0.9.4"
71-
sha2 = "0.9.3"
70+
sha-1 = "0.10.0"
71+
sha2 = "0.10.2"
7272
snap = { version = "1.0.5", optional = true}
7373
socket2 = "0.4.0"
7474
stringprep = "0.1.2"
7575
strsim = "0.10.0"
7676
take_mut = "0.2.2"
7777
thiserror = "1.0.24"
7878
tokio-openssl = { version = "0.6.3", optional = true }
79-
trust-dns-proto = "0.20.0"
80-
trust-dns-resolver = "0.20.0"
81-
typed-builder = "0.9.0"
79+
trust-dns-proto = "0.21.1"
80+
trust-dns-resolver = "0.21.1"
81+
typed-builder = "0.10.0"
8282
version_check = "0.9.1"
83-
webpki = "0.21.0"
84-
webpki-roots = "0.21.0"
85-
zstd = { version = "0.10", optional = true }
83+
webpki-roots = "0.22.2"
84+
zstd = { version = "0.11.0", optional = true }
8685

8786
[dependencies.async-std]
8887
version = "1.9.0"
8988
optional = true
9089

9190
[dependencies.async-std-resolver]
92-
version = "0.20.1"
91+
version = "0.21.1"
9392
optional = true
9493

9594
[dependencies.pbkdf2]
96-
version = "0.8"
95+
version = "0.10.1"
9796
default-features = false
9897

9998
[dependencies.reqwest]
@@ -103,7 +102,7 @@ default-features = false
103102
features = ["json", "rustls-tls"]
104103

105104
[dependencies.rustls]
106-
version = "0.19.0"
105+
version = "0.20.4"
107106
features = ["dangerous_configuration"]
108107

109108
[dependencies.serde]
@@ -119,24 +118,24 @@ version = "1.4.0"
119118
features = ["io-util", "sync", "macros"]
120119

121120
[dependencies.tokio-rustls]
122-
version = "0.22.0"
121+
version = "0.23.2"
123122
features = ["dangerous_configuration"]
124123

125124
[dependencies.tokio-util]
126-
version = "0.6.5"
125+
version = "0.7.0"
127126
features = ["io"]
128127

129128
[dependencies.uuid]
130129
version = "0.8.2"
131130
features = ["v4"]
132131

133132
[dev-dependencies]
134-
approx = "0.4.0"
133+
approx = "0.5.1"
135134
derive_more = "0.99.13"
136135
function_name = "0.2.0"
137136
futures = "0.3"
138137
home = "0.5"
139-
pretty_assertions = "0.7.1"
138+
pretty_assertions = "1.1.0"
140139
serde_json = "1.0.64"
141140
semver = "1.0.0"
142141

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ This repository contains the officially supported MongoDB Rust driver, a client
2929

3030
## Installation
3131
### Requirements
32-
- Rust 1.49+
32+
- Rust 1.51+
3333
- MongoDB 3.6+
3434

3535
### Importing
@@ -358,7 +358,7 @@ Commits to master are run automatically on [evergreen](https://evergreen.mongodb
358358

359359
## Minimum supported Rust version (MSRV)
360360

361-
The MSRV for this crate is currently 1.49.0. This will be rarely be increased, and if it ever is,
361+
The MSRV for this crate is currently 1.51.0. This will be rarely be increased, and if it ever is,
362362
it will only happen in a minor or major version release.
363363

364364
## License

src/client/auth/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ mod x509;
1212

1313
use std::{borrow::Cow, fmt::Debug, str::FromStr};
1414

15-
use hmac::{Mac, NewMac};
15+
use hmac::{digest::KeyInit, Mac};
1616
use rand::Rng;
1717
use serde::Deserialize;
1818
use typed_builder::TypedBuilder;
@@ -515,13 +515,13 @@ pub(crate) fn generate_nonce() -> String {
515515
base64::encode(&result)
516516
}
517517

518-
fn mac<M: Mac + NewMac>(
518+
fn mac<M: Mac + KeyInit>(
519519
key: &[u8],
520520
input: &[u8],
521521
auth_mechanism: &str,
522522
) -> Result<impl AsRef<[u8]>> {
523-
let mut mac =
524-
M::new_from_slice(key).map_err(|_| Error::unknown_authentication_error(auth_mechanism))?;
523+
let mut mac = <M as Mac>::new_from_slice(key)
524+
.map_err(|_| Error::unknown_authentication_error(auth_mechanism))?;
525525
mac.update(input);
526526
Ok(mac.finalize().into_bytes())
527527
}

src/client/auth/scram.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ use std::{
66
str,
77
};
88

9-
use hmac::{digest::Digest, Hmac, Mac, NewMac};
9+
use hmac::{
10+
digest::{Digest, FixedOutput, KeyInit},
11+
Hmac,
12+
Mac,
13+
};
1014
use lazy_static::lazy_static;
1115
use md5::Md5;
1216
use sha1::Sha1;
@@ -352,11 +356,11 @@ fn xor(lhs: &[u8], rhs: &[u8]) -> Vec<u8> {
352356
.collect()
353357
}
354358

355-
fn mac_verify<M: Mac + NewMac>(key: &[u8], input: &[u8], signature: &[u8]) -> Result<()> {
356-
let mut mac =
357-
M::new_from_slice(key).map_err(|_| Error::unknown_authentication_error("SCRAM"))?;
359+
fn mac_verify<M: Mac + KeyInit>(key: &[u8], input: &[u8], signature: &[u8]) -> Result<()> {
360+
let mut mac = <M as Mac>::new_from_slice(key)
361+
.map_err(|_| Error::unknown_authentication_error("SCRAM"))?;
358362
mac.update(input);
359-
match mac.verify(signature) {
363+
match mac.verify_slice(signature) {
360364
Ok(_) => Ok(()),
361365
Err(_) => Err(Error::authentication_error(
362366
"SCRAM",
@@ -371,7 +375,7 @@ fn hash<D: Digest>(val: &[u8]) -> Vec<u8> {
371375
hash.finalize().to_vec()
372376
}
373377

374-
fn h_i<M: Mac + NewMac + Sync>(
378+
fn h_i<M: KeyInit + FixedOutput + Mac + Sync + Clone>(
375379
str: &str,
376380
salt: &[u8],
377381
iterations: u32,

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//! # Installation
99
//!
1010
//! ## Requirements
11-
//! - Rust 1.49+
11+
//! - Rust 1.51+
1212
//! - MongoDB 3.6+
1313
//!
1414
//! ## Importing
@@ -283,7 +283,7 @@
283283
//!
284284
//! ## Minimum supported Rust version (MSRV)
285285
//!
286-
//! The MSRV for this crate is currently 1.49.0. This will be rarely be increased, and if it ever is,
286+
//! The MSRV for this crate is currently 1.51.0. This will be rarely be increased, and if it ever is,
287287
//! it will only happen in a minor or major version release.
288288
289289
#![warn(missing_docs)]

src/runtime/tls_rustls.rs

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
use std::{
2+
convert::TryFrom,
23
fs::File,
34
io::{BufReader, Seek, SeekFrom},
45
pin::Pin,
56
sync::Arc,
67
task::{Context, Poll},
8+
time::SystemTime,
79
};
810

911
use futures_io::{AsyncRead, AsyncWrite};
1012
use rustls::{
11-
internal::pemfile,
13+
client::{ClientConfig, ServerCertVerified, ServerCertVerifier, ServerName},
1214
Certificate,
15+
Error as TlsError,
16+
OwnedTrustAnchor,
1317
RootCertStore,
14-
ServerCertVerified,
15-
ServerCertVerifier,
16-
TLSError,
1718
};
18-
use rustls_pemfile::{read_one, Item};
19+
use rustls_pemfile::{certs, read_one, Item};
1920
use tokio::io::AsyncWrite as TokioAsyncWrite;
2021
use tokio_rustls::TlsConnector;
21-
use webpki::DNSNameRef;
2222
use webpki_roots::TLS_SERVER_ROOTS;
2323

2424
use crate::{
@@ -39,7 +39,7 @@ impl AsyncTlsStream {
3939
tcp_stream: AsyncTcpStream,
4040
cfg: TlsOptions,
4141
) -> Result<Self> {
42-
let name = DNSNameRef::try_from_ascii_str(host).map_err(|e| ErrorKind::DnsResolve {
42+
let name = ServerName::try_from(host).map_err(|e| ErrorKind::DnsResolve {
4343
message: format!("could not resolve {:?}: {}", host, e),
4444
})?;
4545
let mut tls_config = make_rustls_config(cfg)?;
@@ -82,39 +82,38 @@ impl AsyncWrite for AsyncTlsStream {
8282

8383
/// Converts `TlsOptions` into a rustls::ClientConfig.
8484
fn make_rustls_config(cfg: TlsOptions) -> Result<rustls::ClientConfig> {
85-
let mut config = rustls::ClientConfig::new();
86-
87-
if let Some(true) = cfg.allow_invalid_certificates {
88-
config
89-
.dangerous()
90-
.set_certificate_verifier(Arc::new(NoCertVerifier {}));
91-
}
92-
9385
let mut store = RootCertStore::empty();
9486
if let Some(path) = cfg.ca_file_path {
95-
store
96-
.add_pem_file(&mut BufReader::new(File::open(&path)?))
97-
.map_err(|_| ErrorKind::InvalidTlsConfig {
87+
let ders = certs(&mut BufReader::new(File::open(&path)?)).map_err(|_| {
88+
ErrorKind::InvalidTlsConfig {
9889
message: format!(
9990
"Unable to parse PEM-encoded root certificate from {}",
10091
path.display()
10192
),
102-
})?;
93+
}
94+
})?;
95+
store.add_parsable_certificates(&ders);
10396
} else {
104-
store.add_server_trust_anchors(&TLS_SERVER_ROOTS);
97+
let trust_anchors = TLS_SERVER_ROOTS.0.iter().map(|ta| {
98+
OwnedTrustAnchor::from_subject_spki_name_constraints(
99+
ta.subject,
100+
ta.spki,
101+
ta.name_constraints,
102+
)
103+
});
104+
store.add_server_trust_anchors(trust_anchors);
105105
}
106106

107-
config.root_store = store;
108-
109-
if let Some(path) = cfg.cert_key_file_path {
107+
let mut config = if let Some(path) = cfg.cert_key_file_path {
110108
let mut file = BufReader::new(File::open(&path)?);
111-
let certs = match pemfile::certs(&mut file) {
112-
Ok(certs) => certs,
113-
Err(()) => {
109+
let certs = match certs(&mut file) {
110+
Ok(certs) => certs.into_iter().map(Certificate).collect(),
111+
Err(error) => {
114112
return Err(ErrorKind::InvalidTlsConfig {
115113
message: format!(
116-
"Unable to parse PEM-encoded client certificate from {}",
117-
path.display()
114+
"Unable to parse PEM-encoded client certificate from {}: {}",
115+
path.display(),
116+
error,
118117
),
119118
}
120119
.into())
@@ -146,11 +145,24 @@ fn make_rustls_config(cfg: TlsOptions) -> Result<rustls::ClientConfig> {
146145
}
147146
};
148147

148+
ClientConfig::builder()
149+
.with_safe_defaults()
150+
.with_root_certificates(store)
151+
.with_single_cert(certs, key)
152+
.map_err(|error| ErrorKind::InvalidTlsConfig {
153+
message: error.to_string(),
154+
})?
155+
} else {
156+
ClientConfig::builder()
157+
.with_safe_defaults()
158+
.with_root_certificates(store)
159+
.with_no_client_auth()
160+
};
161+
162+
if let Some(true) = cfg.allow_invalid_certificates {
149163
config
150-
.set_single_client_cert(certs, key)
151-
.map_err(|e| ErrorKind::InvalidTlsConfig {
152-
message: e.to_string(),
153-
})?;
164+
.dangerous()
165+
.set_certificate_verifier(Arc::new(NoCertVerifier {}));
154166
}
155167

156168
Ok(config)
@@ -161,11 +173,13 @@ struct NoCertVerifier {}
161173
impl ServerCertVerifier for NoCertVerifier {
162174
fn verify_server_cert(
163175
&self,
164-
_: &RootCertStore,
176+
_: &Certificate,
165177
_: &[Certificate],
166-
_: webpki::DNSNameRef,
178+
_: &ServerName,
179+
_: &mut dyn Iterator<Item = &[u8]>,
167180
_: &[u8],
168-
) -> std::result::Result<ServerCertVerified, TLSError> {
181+
_: SystemTime,
182+
) -> std::result::Result<ServerCertVerified, TlsError> {
169183
Ok(ServerCertVerified::assertion())
170184
}
171185
}

src/srv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ impl SrvResolver {
8080
let mut min_ttl = u32::MAX;
8181

8282
for record in srv_lookup.as_lookup().record_iter() {
83-
let srv = match record.rdata() {
84-
RData::SRV(s) => s,
83+
let srv = match record.data() {
84+
Some(RData::SRV(s)) => s,
8585
_ => continue,
8686
};
8787

0 commit comments

Comments
 (0)