From 9da62ebf10821ace8dee73af8026631481a8ac25 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Tue, 4 Feb 2025 09:33:41 +0100 Subject: [PATCH] Nicer error message on private key read or decode failure --- pdns/recursordist/rec-rust-lib/rust/src/web.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pdns/recursordist/rec-rust-lib/rust/src/web.rs b/pdns/recursordist/rec-rust-lib/rust/src/web.rs index e9a394d5a4..d131b163af 100644 --- a/pdns/recursordist/rec-rust-lib/rust/src/web.rs +++ b/pdns/recursordist/rec-rust-lib/rust/src/web.rs @@ -959,7 +959,10 @@ pub fn serveweb( .spawn(move || { runtime.block_on(async { while let Some(res) = set.join_next().await { - let msg = format!("{:?}", res); + let msg = match res { + Ok(Err(wrapped)) => format!("{:?}", wrapped), + _ => format!("{:?}", res) + }; rustmisc::error( &ctx.logger, rustmisc::Priority::Error, @@ -1000,7 +1003,15 @@ fn load_private_key(filename: &str) -> std::io::Result Ok(pkey), + Ok(None) => Err( + std::io::Error::new( + std::io::ErrorKind::Other, + format!("failed to parse private key from {}", filename), + )), + Err(e) => Err(e) + } } // impl below needed because the classes are used in the Context, which gets passed around. -- 2.47.2