Skip to content

Commit 2d6e1c3

Browse files
cpudjc
authored andcommitted
Cargo: update to rustls 0.22
This commit updates to rustls 0.22, taking the following associated updates: * rustls 0.22.0-alpha-6 -> 0.22 * pki-types 0.2 -> 1 * tokio-rustls 0.25.0-alpha.4 -> 0.25 * rustls-native-certs 0.7.0-alpha.3 -> 0.7 * webpki-roots 0.26.0-alpha.2 -> 0.26 * rustls-pemfile 2.0.0-alpha.2 -> 2 Breaking API changes are addressed as required. Notably, the builder fns that accept a custom provider and use the safe defaults are now fallible to account for a possible error if the provider's configuration is not compatible with the default safe protocol versions.
1 parent 29573af commit 2d6e1c3

File tree

4 files changed

+26
-41
lines changed

4 files changed

+26
-41
lines changed

Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ documentation = "https://docs.rs/hyper-rustls/"
1414
http = "0.2"
1515
hyper = { version = "0.14", default-features = false, features = ["client"] }
1616
log = { version = "0.4.4", optional = true }
17-
pki-types = { package = "rustls-pki-types", version = "0.2" }
18-
rustls-native-certs = { version = "=0.7.0-alpha.3", optional = true }
19-
rustls = { version = "=0.22.0-alpha.6", default-features = false }
17+
pki-types = { package = "rustls-pki-types", version = "1" }
18+
rustls-native-certs = { version = "0.7", optional = true }
19+
rustls = { version = "0.22", default-features = false }
2020
tokio = "1.0"
21-
tokio-rustls = { version = "=0.25.0-alpha.4", default-features = false }
22-
webpki-roots = { version = "=0.26.0-alpha.2", optional = true }
21+
tokio-rustls = { version = "0.25", default-features = false }
22+
webpki-roots = { version = "0.26", optional = true }
2323
futures-util = { version = "0.3", default-features = false }
2424

2525
[dev-dependencies]
2626
hyper = { version = "0.14", features = ["full"] }
27-
rustls = { version = "=0.22.0-alpha.6", default-features = false, features = ["tls12"] }
28-
rustls-pemfile = "=2.0.0-alpha.2"
27+
rustls = { version = "0.22", default-features = false, features = ["tls12"] }
28+
rustls-pemfile = "2"
2929
tokio = { version = "1.0", features = ["io-std", "macros", "net", "rt-multi-thread"] }
3030

3131
[features]

examples/client.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,11 @@ async fn run_client() -> io::Result<()> {
5252
roots.add_parsable_certificates(certs);
5353
// TLS client config using the custom CA store for lookups
5454
rustls::ClientConfig::builder()
55-
.with_safe_defaults()
5655
.with_root_certificates(roots)
5756
.with_no_client_auth()
5857
}
5958
// Default TLS client config with native roots
6059
None => rustls::ClientConfig::builder()
61-
.with_safe_defaults()
6260
.with_native_roots()?
6361
.with_no_client_auth(),
6462
};

src/acceptor/builder.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ impl AcceptorBuilder<WantsTlsConfig> {
2222
AcceptorBuilder(WantsAlpn(config))
2323
}
2424

25-
/// Use rustls [defaults][with_safe_defaults] without [client authentication][with_no_client_auth]
25+
/// Use rustls default crypto provider and safe defaults without
26+
/// [client authentication][with_no_client_auth]
2627
///
27-
/// [with_safe_defaults]: rustls::ConfigBuilder::with_safe_defaults
2828
/// [with_no_client_auth]: rustls::ConfigBuilder::with_no_client_auth
2929
pub fn with_single_cert(
3030
self,
@@ -33,7 +33,6 @@ impl AcceptorBuilder<WantsTlsConfig> {
3333
) -> Result<AcceptorBuilder<WantsAlpn>, rustls::Error> {
3434
Ok(AcceptorBuilder(WantsAlpn(
3535
ServerConfig::builder()
36-
.with_safe_defaults()
3736
.with_no_client_auth()
3837
.with_single_cert(cert_chain, key_der)?,
3938
)))

src/connector/builder.rs

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -52,74 +52,64 @@ impl ConnectorBuilder<WantsTlsConfig> {
5252
ConnectorBuilder(WantsSchemes { tls_config: config })
5353
}
5454

55-
/// Shorthand for using rustls' [safe defaults][with_safe_defaults]
56-
/// and native roots
55+
/// Shorthand for using rustls' default crypto provider and safe defaults, with
56+
/// native roots.
5757
///
5858
/// See [`ConfigBuilderExt::with_native_roots`]
59-
///
60-
/// [with_safe_defaults]: rustls::ConfigBuilder::with_safe_defaults
6159
#[cfg(all(feature = "ring", feature = "rustls-native-certs"))]
6260
pub fn with_native_roots(self) -> std::io::Result<ConnectorBuilder<WantsSchemes>> {
6361
Ok(self.with_tls_config(
6462
ClientConfig::builder()
65-
.with_safe_defaults()
6663
.with_native_roots()?
6764
.with_no_client_auth(),
6865
))
6966
}
7067

71-
/// Shorthand for using rustls' [safe defaults][with_safe_defaults]
72-
/// with a custom [`CryptoProvider`] and native roots
68+
/// Shorthand for using a custom [`CryptoProvider`] and native roots
7369
///
7470
/// See [`ConfigBuilderExt::with_native_roots`]
75-
///
76-
/// [with_safe_defaults]: rustls::ConfigBuilder::with_safe_defaults
7771
#[cfg(feature = "rustls-native-certs")]
7872
pub fn with_provider_and_native_roots(
7973
self,
80-
provider: &'static dyn CryptoProvider,
74+
provider: CryptoProvider,
8175
) -> std::io::Result<ConnectorBuilder<WantsSchemes>> {
8276
Ok(self.with_tls_config(
83-
ClientConfig::builder_with_provider(provider)
84-
.with_safe_defaults()
77+
ClientConfig::builder_with_provider(provider.into())
78+
.with_safe_default_protocol_versions()
79+
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?
8580
.with_native_roots()?
8681
.with_no_client_auth(),
8782
))
8883
}
8984

90-
/// Shorthand for using rustls' [safe defaults][with_safe_defaults]
91-
/// and Mozilla roots
85+
/// Shorthand for using rustls' default crypto provider and its
86+
/// safe defaults.
9287
///
9388
/// See [`ConfigBuilderExt::with_webpki_roots`]
94-
///
95-
/// [with_safe_defaults]: rustls::ConfigBuilder::with_safe_defaults
9689
#[cfg(all(feature = "ring", feature = "webpki-roots"))]
9790
pub fn with_webpki_roots(self) -> ConnectorBuilder<WantsSchemes> {
9891
self.with_tls_config(
9992
ClientConfig::builder()
100-
.with_safe_defaults()
10193
.with_webpki_roots()
10294
.with_no_client_auth(),
10395
)
10496
}
10597

106-
/// Shorthand for using rustls' [safe defaults][with_safe_defaults]
107-
/// with a custom [`CryptoProvider`] and Mozilla roots
98+
/// Shorthand for using a custom [`CryptoProvider`], Rustls' safe default
99+
/// protocol versions and Mozilla roots
108100
///
109101
/// See [`ConfigBuilderExt::with_webpki_roots`]
110-
///
111-
/// [with_safe_defaults]: rustls::ConfigBuilder::with_safe_defaults
112102
#[cfg(feature = "webpki-roots")]
113103
pub fn with_provider_and_webpki_roots(
114104
self,
115-
provider: &'static dyn CryptoProvider,
116-
) -> ConnectorBuilder<WantsSchemes> {
117-
self.with_tls_config(
118-
ClientConfig::builder_with_provider(provider)
119-
.with_safe_defaults()
105+
provider: CryptoProvider,
106+
) -> Result<ConnectorBuilder<WantsSchemes>, rustls::Error> {
107+
Ok(self.with_tls_config(
108+
ClientConfig::builder_with_provider(provider.into())
109+
.with_safe_default_protocol_versions()?
120110
.with_webpki_roots()
121111
.with_no_client_auth(),
122-
)
112+
))
123113
}
124114
}
125115

@@ -331,7 +321,6 @@ mod tests {
331321
fn test_reject_predefined_alpn() {
332322
let roots = rustls::RootCertStore::empty();
333323
let mut config_with_alpn = rustls::ClientConfig::builder()
334-
.with_safe_defaults()
335324
.with_root_certificates(roots)
336325
.with_no_client_auth();
337326
config_with_alpn.alpn_protocols = vec![b"fancyprotocol".to_vec()];
@@ -347,7 +336,6 @@ mod tests {
347336
fn test_alpn() {
348337
let roots = rustls::RootCertStore::empty();
349338
let tls_config = rustls::ClientConfig::builder()
350-
.with_safe_defaults()
351339
.with_root_certificates(roots)
352340
.with_no_client_auth();
353341
let connector = super::ConnectorBuilder::new()

0 commit comments

Comments
 (0)