diff --git a/Cargo.toml b/Cargo.toml index c37d2a33..0083b7de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,7 +61,7 @@ viz-smol = { version = "0.1.5", path = "viz-smol" } anyhow = "1.0" async-trait = "0.1" -bytes = "1.5" +bytes = "1.6" serde = "1.0" serde_derive = "1.0" serde_json = "1.0" @@ -70,7 +70,7 @@ sync_wrapper = "1.0" thiserror = "1.0" # router -path-tree = "0.7.6" +path-tree = "0.7.7" # session sessions = "0.6" @@ -82,7 +82,7 @@ headers = "0.4" http = "1.1" http-body = "1" http-body-util = "0.1" -hyper = { version = "1.2", features = ["server"] } +hyper = { version = "1.3", features = ["server"] } hyper-util = { version = "0.1.3", features = ["server-auto", "tokio"] } mime = "0.3" mime_guess = "2.0" @@ -92,10 +92,10 @@ hex = "0.4" rust-embed = "8" futures-util = "0.3" -rustls-pemfile = "1.0" -tokio = { version = "1.36", features = ["net"] } +rustls-pemfile = "2.0" +tokio = { version = "1.37", features = ["net"] } tokio-native-tls = "0.3" -tokio-rustls = "0.24" +tokio-rustls = "0.26" tokio-stream = "0.1" tokio-tungstenite = "0.21" tokio-util = "0.7" @@ -117,15 +117,15 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] } tower = "0.4" tower-http = "0.5" -# soml +# Soml async-channel = "2.2" -async-executor = "1.8" -async-io = "2.2" +async-executor = "1.11" +async-io = "2.3" async-net = "2.0" smol-hyper = "0.1.1" smol-macros = "0.1" macro_rules_attribute = "0.2" -futures-lite = { version = "2.1.0", default-features = false, features = ["std"] } +futures-lite = { version = "2.3", default-features = false, features = ["std"] } [workspace.metadata.docs.rs] all-features = true diff --git a/examples/htmlx/Cargo.toml b/examples/htmlx/Cargo.toml index a4f31ad2..37445eae 100644 --- a/examples/htmlx/Cargo.toml +++ b/examples/htmlx/Cargo.toml @@ -12,4 +12,4 @@ serde_json.workspace = true tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } handlebars = { version = "5", features = ["dir_source"] } -once_cell = "1.19" +once_cell = "1" diff --git a/examples/limits/Cargo.toml b/examples/limits/Cargo.toml index a9317da1..fde5fdd5 100644 --- a/examples/limits/Cargo.toml +++ b/examples/limits/Cargo.toml @@ -7,5 +7,5 @@ publish = false [dependencies] viz = { workspace = true, features = ["limits", "json", "form", "multipart"] } -serde = { version = "1.0", features = ["derive"] } +serde = { workspace = true, features = ["derive"] } tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } diff --git a/examples/routing/openapi/Cargo.toml b/examples/routing/openapi/Cargo.toml index c8599a97..43c07a2c 100644 --- a/examples/routing/openapi/Cargo.toml +++ b/examples/routing/openapi/Cargo.toml @@ -13,4 +13,4 @@ serde_json.workspace = true tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } utoipa = "4" -utoipa-swagger-ui = "6" +utoipa-swagger-ui = "7" diff --git a/examples/static-files/include-dir/Cargo.toml b/examples/static-files/include-dir/Cargo.toml index e4e53903..23d4aebc 100644 --- a/examples/static-files/include-dir/Cargo.toml +++ b/examples/static-files/include-dir/Cargo.toml @@ -6,7 +6,7 @@ publish = false [dependencies] viz.workspace = true +http-body-util.workspace = true tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } include_dir = "0.7" -http-body-util = "0.1" diff --git a/examples/static-routes/Cargo.toml b/examples/static-routes/Cargo.toml index b8a82479..dfbc0601 100644 --- a/examples/static-routes/Cargo.toml +++ b/examples/static-routes/Cargo.toml @@ -9,4 +9,4 @@ viz.workspace = true hyper.workspace = true tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } -once_cell = "1.19" +once_cell = "1" diff --git a/examples/templates/askama/Cargo.toml b/examples/templates/askama/Cargo.toml index 4ea7bf7b..2cd7ebef 100644 --- a/examples/templates/askama/Cargo.toml +++ b/examples/templates/askama/Cargo.toml @@ -8,4 +8,5 @@ publish = false viz.workspace = true tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } + askama = "0.12" diff --git a/examples/templates/maud/Cargo.toml b/examples/templates/maud/Cargo.toml index 49e22e8e..ff65ad48 100644 --- a/examples/templates/maud/Cargo.toml +++ b/examples/templates/maud/Cargo.toml @@ -8,4 +8,5 @@ publish = false viz.workspace = true tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } + maud = "0.26" diff --git a/examples/templates/minijinja/Cargo.toml b/examples/templates/minijinja/Cargo.toml index 13d13072..d9e1fd7f 100644 --- a/examples/templates/minijinja/Cargo.toml +++ b/examples/templates/minijinja/Cargo.toml @@ -9,5 +9,5 @@ viz.workspace = true serde.workspace = true tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } -minijinja = { version = "1", features = ["loader"] } +minijinja = { version = "2", features = ["loader"] } once_cell = "1.19" diff --git a/examples/templates/tera/Cargo.toml b/examples/templates/tera/Cargo.toml index 0de34112..763bd7c3 100644 --- a/examples/templates/tera/Cargo.toml +++ b/examples/templates/tera/Cargo.toml @@ -9,5 +9,6 @@ viz.workspace = true serde.workspace = true tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } -tera = "1.18" -once_cell = "1.19" + +tera = "1.19" +once_cell = "1" diff --git a/viz-core/Cargo.toml b/viz-core/Cargo.toml index b5a3f78d..a4dd6ed1 100644 --- a/viz-core/Cargo.toml +++ b/viz-core/Cargo.toml @@ -71,7 +71,7 @@ mime.workspace = true rfc7239 = "0.1" # realip cookie = { version = "0.18", features = ["percent-encode"], optional = true } -form-data = { version = "0.5.3", optional = true } +form-data = { version = "0.5.5", optional = true } serde = { workspace = true, features = ["derive"], optional = true } serde_json = { workspace = true, optional = true } serde_urlencoded = { workspace = true, optional = true } diff --git a/viz-handlers/src/serve/directory.rs b/viz-handlers/src/serve/directory.rs index 900f2f3c..88d015fc 100644 --- a/viz-handlers/src/serve/directory.rs +++ b/viz-handlers/src/serve/directory.rs @@ -133,7 +133,7 @@ pub(crate) struct Files(Vec<(String, String, bool, Option, String)>); impl Display for Files { fn fmt(&self, f: &mut Formatter<'_>) -> Result { - #[allow(clippy::manual_unwrap_or_default)] + #[allow(clippy::unwrap_or_default)] for (relative, title, kind, ext, base) in &self.0 { writeln!( f, diff --git a/viz-smol/src/lib.rs b/viz-smol/src/lib.rs index 70fd9682..98efdab4 100644 --- a/viz-smol/src/lib.rs +++ b/viz-smol/src/lib.rs @@ -63,8 +63,8 @@ pub use listener::Listener; mod server; pub use server::serve; -#[cfg(any(feature = "native_tls", feature = "rustls"))] -pub use server::tls; +// #[cfg(any(feature = "native_tls", feature = "rustls"))] +// pub use server::tls; pub use viz_core::*; pub use viz_router::*; diff --git a/viz-smol/src/server.rs b/viz-smol/src/server.rs index b2360cff..7ecb1592 100644 --- a/viz-smol/src/server.rs +++ b/viz-smol/src/server.rs @@ -15,8 +15,8 @@ mod tcp; mod unix; /// TLS -#[cfg(any(feature = "native_tls", feature = "rustls"))] -pub mod tls; +// #[cfg(any(feature = "native_tls", feature = "rustls"))] +// pub mod tls; /// Serve a server with smol's networking types. #[allow(clippy::missing_errors_doc)] diff --git a/viz/Cargo.toml b/viz/Cargo.toml index 68b86b85..d2a7245c 100644 --- a/viz/Cargo.toml +++ b/viz/Cargo.toml @@ -51,8 +51,8 @@ cors = ["viz-core/cors"] compression = ["viz-core/compression"] -http1 = ["hyper/http1"] -http2 = ["hyper/http2"] +http1 = ["hyper/http1", "hyper-util/http1"] +http2 = ["hyper/http2", "hyper-util/http2"] unix-socket = [] @@ -83,9 +83,9 @@ futures-util = { workspace = true, optional = true } tracing.workspace = true rustls-pemfile = { workspace = true, optional = true } - tokio-native-tls = { workspace = true, optional = true } tokio-rustls = { workspace = true, optional = true } + tokio = { workspace = true, features = ["macros"] } tokio-util = { workspace = true, features = ["net"] } diff --git a/viz/src/server/tls/rustls.rs b/viz/src/server/tls/rustls.rs index 1a84a25c..8498ee0d 100644 --- a/viz/src/server/tls/rustls.rs +++ b/viz/src/server/tls/rustls.rs @@ -5,12 +5,7 @@ use std::{ use tokio::net::{TcpListener, TcpStream}; use tokio_rustls::{ - rustls::{ - server::{ - AllowAnyAnonymousOrAuthenticatedClient, AllowAnyAuthenticatedClient, NoClientAuth, - }, - Certificate, PrivateKey, RootCertStore, ServerConfig, - }, + rustls::{pki_types::PrivateKeyDer, server::WebPkiClientVerifier, RootCertStore, ServerConfig}, server::TlsStream, }; @@ -95,26 +90,29 @@ impl Config { /// /// # Errors pub fn build(self) -> Result { - fn read_trust_anchor(trust_anchor: &Certificate) -> Result { + fn read_trust_anchor(mut trust_anchor: &[u8]) -> Result { + let certs = rustls_pemfile::certs(&mut trust_anchor) + .collect::>>() + .map_err(Error::boxed)?; let mut store = RootCertStore::empty(); - store.add(trust_anchor).map_err(Error::boxed)?; + for cert in certs { + store.add(cert).map_err(Error::boxed)?; + } Ok(store) } let certs = rustls_pemfile::certs(&mut self.cert.as_slice()) - .map(|mut certs| certs.drain(..).map(Certificate).collect()) + .collect::, _>>() .map_err(Error::boxed)?; let keys = { - let mut pkcs8: Vec = - rustls_pemfile::pkcs8_private_keys(&mut self.key.as_slice()) - .map(|mut keys| keys.drain(..).map(PrivateKey).collect()) - .map_err(Error::boxed)?; + let mut pkcs8 = rustls_pemfile::pkcs8_private_keys(&mut self.key.as_slice()) + .collect::, _>>() + .map_err(Error::boxed)?; if pkcs8.is_empty() { - let mut rsa: Vec = - rustls_pemfile::rsa_private_keys(&mut self.key.as_slice()) - .map(|mut keys| keys.drain(..).map(PrivateKey).collect()) - .map_err(Error::boxed)?; + let mut rsa = rustls_pemfile::rsa_private_keys(&mut self.key.as_slice()) + .collect::, _>>() + .map_err(Error::boxed)?; if rsa.is_empty() { return Err(Error::boxed(IoError::new( @@ -122,28 +120,30 @@ impl Config { "failed to parse tls private keys", ))); } - rsa.remove(0) + PrivateKeyDer::Pkcs1(rsa.remove(0)) } else { - pkcs8.remove(0) + PrivateKeyDer::Pkcs8(pkcs8.remove(0)) } }; let client_auth = match self.client_auth { - ClientAuth::Off => NoClientAuth::boxed(), - ClientAuth::Optional(trust_anchor) => AllowAnyAnonymousOrAuthenticatedClient::new( - read_trust_anchor(&Certificate(trust_anchor))?, - ) - .boxed(), + ClientAuth::Off => WebPkiClientVerifier::no_client_auth(), + ClientAuth::Optional(trust_anchor) => { + WebPkiClientVerifier::builder(read_trust_anchor(&trust_anchor)?.into()) + .allow_unauthenticated() + .build() + .map_err(Error::boxed)? + } ClientAuth::Required(trust_anchor) => { - AllowAnyAuthenticatedClient::new(read_trust_anchor(&Certificate(trust_anchor))?) - .boxed() + WebPkiClientVerifier::builder(read_trust_anchor(&trust_anchor)?.into()) + .build() + .map_err(Error::boxed)? } }; ServerConfig::builder() - .with_safe_defaults() .with_client_cert_verifier(client_auth) - .with_single_cert_with_ocsp_and_sct(certs, keys, self.ocsp_resp, Vec::new()) + .with_single_cert_with_ocsp(certs, keys, self.ocsp_resp) .map_err(Error::boxed) } }