From 20a1226eb3d0abd739160264a2834c0281b1c142 Mon Sep 17 00:00:00 2001 From: Hannes de Jager Date: Wed, 19 Jun 2024 22:12:12 +0200 Subject: [PATCH] Fixes This commit fixes - Clippy complaints on the latest Rust version 1.79.0 - Certificate load issues when FTPS are enabled - Compilation error in a test of unftp-sbe-gcs --- crates/unftp-sbe-gcs/tests/main.rs | 1 - src/server/controlchan/codecs.rs | 2 +- src/server/tls.rs | 13 +++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/unftp-sbe-gcs/tests/main.rs b/crates/unftp-sbe-gcs/tests/main.rs index d73fff25..30dfc50f 100644 --- a/crates/unftp-sbe-gcs/tests/main.rs +++ b/crates/unftp-sbe-gcs/tests/main.rs @@ -283,7 +283,6 @@ async fn run_test(test: impl Future) { })) .logger(Some(Logger::root(drain, o!()))) .build() - .await .unwrap() .listen(ADDR), ); diff --git a/src/server/controlchan/codecs.rs b/src/server/controlchan/codecs.rs index 2246f604..cd4008a2 100644 --- a/src/server/controlchan/codecs.rs +++ b/src/server/controlchan/codecs.rs @@ -58,7 +58,7 @@ impl Encoder for FtpCodec { } Reply::MultiLine { code, mut lines } => { // Get the last line since it needs to be preceded by the response code. - let last_line = if let Some(x) = lines.pop() { x } else { String::from("") }; + let last_line = lines.pop().unwrap_or_default(); // Lines starting with a digit should be indented for it in lines.iter_mut() { diff --git a/src/server/tls.rs b/src/server/tls.rs index 4c61d8c7..29f8e15e 100644 --- a/src/server/tls.rs +++ b/src/server/tls.rs @@ -75,12 +75,16 @@ pub fn new_config>( let certs: Vec = load_certs(certs_file)?; let privkey: PrivateKeyDer = load_private_key(key_file)?; - let builder: ClientCertVerifierBuilder = WebPkiClientVerifier::builder(Arc::new(root_cert_store(trust_store)?)); - let client_auther = match client_auth { FtpsClientAuth::Off => Ok(WebPkiClientVerifier::no_client_auth()), - FtpsClientAuth::Request => builder.allow_unauthenticated().build(), - FtpsClientAuth::Require => builder.build(), + FtpsClientAuth::Request => { + let builder: ClientCertVerifierBuilder = WebPkiClientVerifier::builder(Arc::new(root_cert_store(trust_store)?)); + builder.allow_unauthenticated().build() + } + FtpsClientAuth::Require => { + let builder: ClientCertVerifierBuilder = WebPkiClientVerifier::builder(Arc::new(root_cert_store(trust_store)?)); + builder.build() + } } .map_err(ConfigError::ClientVerifier)?; @@ -134,6 +138,7 @@ fn load_certs>(filename: P) -> Result let cert = cert.map_err(ConfigError::Load)?; res.push(cert); } + Ok(res) }