Skip to content

Commit 258525e

Browse files
authored
feat: update rustls to 0.21.0 and tokio-rustls to 0.24 (bytebeamio#606)
1 parent 8859195 commit 258525e

File tree

9 files changed

+66
-45
lines changed

9 files changed

+66
-45
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ perf.data*
1313
node_modules
1414
cachegrind.out
1515
plot
16+
.uuid

Cargo.lock

+46-29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rumqttc/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3434
- Refactored `eventloop::network_connect` to allow setting proxy
3535
- Added proxy options to `MqttOptions`
3636

37+
- Added support for TLS certificates containing IP addresses
38+
- Added support for RFC8446 C.4 client tracking prevention.
39+
3740
### Changed
3841
- Remove `Box` on `Event::Incoming`
3942

rumqttc/Cargo.toml

+6-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ rustdoc-args = ["--cfg", "docsrs"]
1515

1616
[features]
1717
default = ["use-rustls"]
18-
use-rustls = ["dep:tokio-rustls", "dep:rustls-pemfile", "dep:rustls-native-certs"]
18+
use-rustls = ["dep:tokio-rustls", "dep:rustls-webpki", "dep:rustls-pemfile", "dep:rustls-native-certs"]
1919
use-native-tls = ["dep:tokio-native-tls", "dep:native-tls"]
2020
websocket = ["dep:async-tungstenite", "dep:ws_stream_tungstenite", "dep:http"]
2121
proxy = ["dep:async-http-proxy"]
@@ -30,12 +30,13 @@ thiserror = "1"
3030

3131
# Optional
3232
# rustls
33-
tokio-rustls = { version = "0.23", optional = true }
33+
tokio-rustls = { version = "0.24", optional = true }
34+
rustls-webpki = { version = "0.100.1", optional = true }
3435
rustls-pemfile = { version = "1", optional = true }
3536
rustls-native-certs = { version = "0.6", optional = true }
3637
# websockets
37-
async-tungstenite = { version = "0.16", default-features = false, features = ["tokio-rustls-native-certs"], optional = true }
38-
ws_stream_tungstenite = { version = "0.7", default-features = false, features = ["tokio_io"], optional = true }
38+
async-tungstenite = { version = "0.22", default-features = false, features = ["tokio-rustls-native-certs"], optional = true }
39+
ws_stream_tungstenite = { version = "0.10", default-features = false, features = ["tokio_io"], optional = true }
3940
http = { version = "0.2", optional = true }
4041
# native-tls
4142
tokio-native-tls = { version = "0.3.0", optional = true }
@@ -50,7 +51,7 @@ color-backtrace = "0.4"
5051
matches = "0.1"
5152
pretty_assertions = "1"
5253
pretty_env_logger = "0.4"
53-
rustls = "0.20"
54+
rustls = "0.21"
5455
rustls-native-certs = "0.6"
5556
serde = { version = "1", features = ["derive"] }
5657
tokio = { version = "1", features = ["full", "macros"] }

rumqttc/examples/tls.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::error::Error;
55
#[tokio::main]
66
async fn main() -> Result<(), Box<dyn Error>> {
77
use rumqttc::{self, AsyncClient, Event, Incoming, MqttOptions, Transport};
8-
use rustls::ClientConfig;
8+
use tokio_rustls::rustls::ClientConfig;
99

1010
pretty_env_logger::init();
1111
color_backtrace::install();
@@ -15,9 +15,9 @@ async fn main() -> Result<(), Box<dyn Error>> {
1515
mqttoptions.set_credentials("username", "password");
1616

1717
// Use rustls-native-certs to load root certificates from the operating system.
18-
let mut root_cert_store = rustls::RootCertStore::empty();
18+
let mut root_cert_store = tokio_rustls::rustls::RootCertStore::empty();
1919
for cert in rustls_native_certs::load_native_certs().expect("could not load platform certs") {
20-
root_cert_store.add(&rustls::Certificate(cert.0))?;
20+
root_cert_store.add(&tokio_rustls::rustls::Certificate(cert.0))?;
2121
}
2222

2323
let client_config = ClientConfig::builder()

rumqttc/src/tls.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ use tokio_rustls::rustls::{
77
Certificate, ClientConfig, OwnedTrustAnchor, PrivateKey, RootCertStore, ServerName,
88
};
99
#[cfg(feature = "use-rustls")]
10-
use tokio_rustls::webpki;
11-
#[cfg(feature = "use-rustls")]
1210
use tokio_rustls::TlsConnector as RustlsConnector;
1311

1412
#[cfg(feature = "use-rustls")]
@@ -44,8 +42,8 @@ pub enum Error {
4442
/// Certificate/Name validation error
4543
#[error("Web Pki: {0}")]
4644
WebPki(#[from] webpki::Error),
47-
#[cfg(feature = "use-rustls")]
4845
/// Invalid DNS name
46+
#[cfg(feature = "use-rustls")]
4947
#[error("DNS name")]
5048
DNSName(#[from] InvalidDnsNameError),
5149
#[cfg(feature = "use-rustls")]

rumqttd/Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ flume = "0.10.9"
1818
slab = "0.4.3"
1919
thiserror = "1.0.24"
2020
tokio-util = { version = "0.7", features = ["codec"], optional = true }
21-
tokio-rustls = { version = "0.23.0", optional = true }
21+
tokio-rustls = { version = "0.24", optional = true }
22+
rustls-webpki = { version = "0.100.1", optional = true }
2223
tokio-native-tls = { version = "0.3", optional = true }
2324
rustls-pemfile = { version = "1", optional = true }
2425
tokio-tungstenite = { version = "0.15.0", optional = true }
@@ -36,7 +37,7 @@ axum = "0.6.4"
3637

3738
[features]
3839
default = ["use-rustls"]
39-
use-rustls = ["dep:tokio-rustls", "dep:rustls-pemfile", "dep:x509-parser"]
40+
use-rustls = ["dep:tokio-rustls", "dep:rustls-webpki", "dep:rustls-pemfile", "dep:x509-parser"]
4041
use-native-tls = ["dep:tokio-native-tls", "dep:x509-parser"]
4142
websockets = ["dep:tokio-tungstenite", "dep:websocket-codec", "dep:tokio-util", "dep:futures-util"]
4243
validate-tenant-prefix = []

rumqttd/src/link/bridge.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use tokio_rustls::{
2121
client::InvalidDnsNameError, Certificate, ClientConfig, Error as TLSError,
2222
OwnedTrustAnchor, PrivateKey, RootCertStore, ServerName,
2323
},
24-
webpki, TlsConnector,
24+
TlsConnector,
2525
};
2626
use tracing::*;
2727

@@ -319,7 +319,7 @@ pub enum BridgeError {
319319
Network(#[from] network::Error),
320320
#[error("Web Pki - {0}")]
321321
#[cfg(feature = "use-rustls")]
322-
WebPki(#[from] tokio_rustls::webpki::Error),
322+
WebPki(#[from] webpki::Error),
323323
#[error("DNS name - {0}")]
324324
#[cfg(feature = "use-rustls")]
325325
DNSName(#[from] InvalidDnsNameError),

rumqttd/src/server/tls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl TLSAcceptor {
219219

220220
ServerConfig::builder()
221221
.with_safe_defaults()
222-
.with_client_cert_verifier(AllowAnyAuthenticatedClient::new(store))
222+
.with_client_cert_verifier(Arc::new(AllowAnyAuthenticatedClient::new(store)))
223223
.with_single_cert(certs, key)?
224224
};
225225

0 commit comments

Comments
 (0)