From 72d0d1eb4b63b996f9899682274399f6ddb53f85 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 29 Aug 2023 18:56:00 +0100 Subject: [PATCH] fix: remaining upgrade issues --- Cargo.lock | 9 +++++---- https-tls/awc-https/src/main.rs | 4 ++-- https-tls/openssl-auto-le/Cargo.toml | 2 +- https-tls/openssl-auto-le/src/main.rs | 2 +- https-tls/rustls-client-cert/Cargo.toml | 2 +- https-tls/rustls-client-cert/src/main.rs | 6 +++--- websockets/chat-actorless/src/server.rs | 4 ++-- websockets/chat/src/server.rs | 4 ++-- 8 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 904e45c..e072780 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,11 +13,12 @@ dependencies = [ ] [[package]] -name = "acme-lib" -version = "0.8.2" +name = "acme-micro" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "292ac9d513052341a7f5bdae61f31c4dc93c1dce2598508f52709df08cecc8b0" +checksum = "a18fb402a32ddc56ef7015df8d575c326ea911887ba9b7661ce18786282e89a3" dependencies = [ + "anyhow", "base64 0.13.1", "lazy_static", "log", @@ -5091,7 +5092,7 @@ dependencies = [ name = "openssl-auto-le" version = "1.0.0" dependencies = [ - "acme-lib", + "acme-micro", "actix-files", "actix-web", "anyhow", diff --git a/https-tls/awc-https/src/main.rs b/https-tls/awc-https/src/main.rs index e40038c..5847069 100644 --- a/https-tls/awc-https/src/main.rs +++ b/https-tls/awc-https/src/main.rs @@ -49,7 +49,7 @@ async fn main() -> std::io::Result<()> { // Wikipedia requires a User-Agent header to make requests .add_default_header((header::USER_AGENT, "awc-example/1.0")) // a "connector" wraps the stream into an encrypted connection - .connector(Connector::new().rustls(Arc::clone(&client_tls_config))) + .connector(Connector::new().rustls_021(Arc::clone(&client_tls_config))) .finish(); App::new() @@ -66,7 +66,7 @@ async fn main() -> std::io::Result<()> { /// Create simple rustls client config from root certificates. fn rustls_config() -> ClientConfig { let mut root_store = RootCertStore::empty(); - root_store.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| { + root_store.add_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.iter().map(|ta| { OwnedTrustAnchor::from_subject_spki_name_constraints( ta.subject, ta.spki, diff --git a/https-tls/openssl-auto-le/Cargo.toml b/https-tls/openssl-auto-le/Cargo.toml index 66a78c3..0617c4a 100644 --- a/https-tls/openssl-auto-le/Cargo.toml +++ b/https-tls/openssl-auto-le/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" actix-web = { workspace = true, features = ["openssl"] } actix-files.workspace = true -acme-lib = "0.8" +acme-micro = "0.12" anyhow = "1" env_logger.workspace = true log.workspace = true diff --git a/https-tls/openssl-auto-le/src/main.rs b/https-tls/openssl-auto-le/src/main.rs index bd25fb7..7291c50 100644 --- a/https-tls/openssl-auto-le/src/main.rs +++ b/https-tls/openssl-auto-le/src/main.rs @@ -1,6 +1,6 @@ use std::{fs, time::Duration}; -use acme_lib::{create_p384_key, Certificate, Directory, DirectoryUrl}; +use acme_micro::{create_p384_key, Certificate, Directory, DirectoryUrl}; use actix_files::Files; use actix_web::{rt, web, App, HttpRequest, HttpServer, Responder}; use anyhow::anyhow; diff --git a/https-tls/rustls-client-cert/Cargo.toml b/https-tls/rustls-client-cert/Cargo.toml index 0761324..dd25f67 100644 --- a/https-tls/rustls-client-cert/Cargo.toml +++ b/https-tls/rustls-client-cert/Cargo.toml @@ -4,7 +4,7 @@ version = "1.0.0" edition = "2021" [dependencies] -actix-tls.workspace = true +actix-tls = { workspace = true, features = ["rustls-0_21"] } actix-web = { workspace = true, features = ["rustls-0_21"] } env_logger.workspace = true log.workspace = true diff --git a/https-tls/rustls-client-cert/src/main.rs b/https-tls/rustls-client-cert/src/main.rs index ad0a01e..7c6ec3b 100644 --- a/https-tls/rustls-client-cert/src/main.rs +++ b/https-tls/rustls-client-cert/src/main.rs @@ -1,9 +1,9 @@ //! This example shows how to use `actix_web::HttpServer::on_connect` to access client certificates //! pass them to a handler through connection-local data. -use std::{any::Any, fs::File, io::BufReader, net::SocketAddr}; +use std::{any::Any, sync::Arc, fs::File, io::BufReader, net::SocketAddr}; -use actix_tls::accept::rustls::{reexports::ServerConfig, TlsStream}; +use actix_tls::accept::rustls_0_21::{reexports::ServerConfig, TlsStream}; use actix_web::{ dev::Extensions, rt::net::TcpStream, web, App, HttpRequest, HttpResponse, HttpServer, Responder, }; @@ -85,7 +85,7 @@ async fn main() -> std::io::Result<()> { let client_auth = AllowAnyAnonymousOrAuthenticatedClient::new(cert_store); let config = ServerConfig::builder() .with_safe_defaults() - .with_client_cert_verifier(client_auth); + .with_client_cert_verifier(Arc::new(client_auth)); // import server cert and key let cert_file = &mut BufReader::new(File::open(SERVER_CERT)?); diff --git a/websockets/chat-actorless/src/server.rs b/websockets/chat-actorless/src/server.rs index 587256b..9d0f273 100644 --- a/websockets/chat-actorless/src/server.rs +++ b/websockets/chat-actorless/src/server.rs @@ -130,7 +130,7 @@ impl ChatServer { // auto join session to main room self.rooms .entry("main".to_owned()) - .or_insert_with(HashSet::new) + .or_default() .insert(id); let count = self.visitor_count.fetch_add(1, Ordering::SeqCst); @@ -187,7 +187,7 @@ impl ChatServer { self.rooms .entry(room.clone()) - .or_insert_with(HashSet::new) + .or_default() .insert(conn_id); self.send_system_message(&room, conn_id, "Someone connected") diff --git a/websockets/chat/src/server.rs b/websockets/chat/src/server.rs index c5531e3..df4e73f 100644 --- a/websockets/chat/src/server.rs +++ b/websockets/chat/src/server.rs @@ -131,7 +131,7 @@ impl Handler for ChatServer { // auto join session to main room self.rooms .entry("main".to_owned()) - .or_insert_with(HashSet::new) + .or_default() .insert(id); let count = self.visitor_count.fetch_add(1, Ordering::SeqCst); @@ -213,7 +213,7 @@ impl Handler for ChatServer { self.rooms .entry(name.clone()) - .or_insert_with(HashSet::new) + .or_default() .insert(id); self.send_message(&name, "Someone connected", id);