From 83258250c25d505f6e7c6ff29fed3f08433b49fe Mon Sep 17 00:00:00 2001 From: Daniel Abramov Date: Sun, 16 Jun 2024 14:15:02 +0200 Subject: [PATCH 1/3] Prepare 0.23.1 release --- CHANGELOG.md | 2 +- Cargo.toml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c65c4da..92dba21f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# Unreleased +# 0.23.1 - Introduce a `url` feature (proxies to `tungstenite/url`). diff --git a/Cargo.toml b/Cargo.toml index e7e15092..dec1fa2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,9 +6,9 @@ keywords = ["websocket", "io", "web"] authors = ["Daniel Abramov ", "Alexey Galakhov "] license = "MIT" homepage = "https://github.com/snapview/tokio-tungstenite" -documentation = "https://docs.rs/tokio-tungstenite/0.23.0" +documentation = "https://docs.rs/tokio-tungstenite/0.23.1" repository = "https://github.com/snapview/tokio-tungstenite" -version = "0.23.0" +version = "0.23.1" edition = "2018" rust-version = "1.63" include = ["examples/**/*", "src/**/*", "LICENSE", "README.md", "CHANGELOG.md"] From 94a35a0d6bcdc2f07d05f9e3edcbc7fcb1d5b020 Mon Sep 17 00:00:00 2001 From: Brendan Blanchard <141498660+Brendan-Blanchard@users.noreply.github.com> Date: Thu, 8 Aug 2024 08:29:03 -0400 Subject: [PATCH 2/3] Additional Documentation of `IntoClientRequest` on `connect_async` (#342) * Add documentation to `connect_async` * Add hidden async wrapper function * Reduce example, fix doc format * Avoid `main` as the test function name --------- Co-authored-by: Brendan Blanchard --- src/connect.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/connect.rs b/src/connect.rs index 5787af15..989349a9 100644 --- a/src/connect.rs +++ b/src/connect.rs @@ -10,6 +10,24 @@ use tungstenite::{ use crate::{domain, stream::MaybeTlsStream, Connector, IntoClientRequest, WebSocketStream}; /// Connect to a given URL. +/// +/// Accepts any request that implements [`IntoClientRequest`], which is often just `&str`, but can +/// be a variety of types such as `httparse::Request` or [`tungstenite::http::Request`] for more +/// complex uses. +/// +/// ```no_run +/// # use tungstenite::client::IntoClientRequest; +/// +/// # async fn test() { +/// use tungstenite::http::{Method, Request}; +/// use tokio_tungstenite::connect_async; +/// +/// let mut request = "wss://api.example.com".into_client_request().unwrap(); +/// request.headers_mut().insert("api-key", "42".parse().unwrap()); +/// +/// let (stream, response) = connect_async(request).await.unwrap(); +/// # } +/// ``` pub async fn connect_async( request: R, ) -> Result<(WebSocketStream>, Response), Error> From 0b9d97bc148daabc51a36a38a10d0b1b2b13c55e Mon Sep 17 00:00:00 2001 From: nickelc Date: Thu, 5 Sep 2024 19:53:27 +0200 Subject: [PATCH 3/3] deps: update `rustls-native-certs` to 0.8 (#348) The `load_native_certs()` function now returns all errors instead of raising only the first error. Not finding any native root CA certificates is not fatal if the "rustls-tls-webpki-roots" feature is enabled. --- Cargo.toml | 2 +- src/tls.rs | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dec1fa2c..4711060e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,7 +53,7 @@ version = "1.0" [dependencies.rustls-native-certs] optional = true -version = "0.7.0" +version = "0.8.0" [dependencies.tokio-native-tls] optional = true diff --git a/src/tls.rs b/src/tls.rs index 7fe7329b..4863914c 100644 --- a/src/tls.rs +++ b/src/tls.rs @@ -95,10 +95,26 @@ mod encryption { let mut root_store = RootCertStore::empty(); #[cfg(feature = "rustls-tls-native-roots")] { - let native_certs = rustls_native_certs::load_native_certs()?; - let total_number = native_certs.len(); + let rustls_native_certs::CertificateResult { + certs, errors, .. + } = rustls_native_certs::load_native_certs(); + + if !errors.is_empty() { + log::warn!( + "native root CA certificate loading errors: {errors:?}" + ); + } + + // Not finding any native root CA certificates is not fatal if the + // "rustls-tls-webpki-roots" feature is enabled. + #[cfg(not(feature = "rustls-tls-webpki-roots"))] + if certs.is_empty() { + return Err(std::io::Error::new(std::io::ErrorKind::NotFound, format!("no native root CA certificates found (errors: {errors:?})")).into()); + } + + let total_number = certs.len(); let (number_added, number_ignored) = - root_store.add_parsable_certificates(native_certs); + root_store.add_parsable_certificates(certs); log::debug!("Added {number_added}/{total_number} native root certificates (ignored {number_ignored})"); } #[cfg(feature = "rustls-tls-webpki-roots")]