diff --git a/src/main.rs b/src/main.rs index 894b037..c2e71ed 100644 --- a/src/main.rs +++ b/src/main.rs @@ -114,9 +114,16 @@ async fn racme(flags: Arguments) -> Result<(), Error> { ReadDirStream::new(rd) }; let mut siteconfigs = Vec::new(); - for file in files.filter(Result::is_ok).map(|file| file.unwrap().path()).collect::>().await { - let mut site = SiteConfig::from_file(FILE_MODE.open(file.clone()).await.unwrap()).await; - site.name = file.file_stem().unwrap().to_str().unwrap().to_string(); + for filename in files.filter(Result::is_ok).map(|file| file.unwrap().path()).collect::>().await { + let file = match FILE_MODE.open(filename.clone()).await { + Ok(file) => file, + Err(error) => { + warn!("Failed to read the configfile {}: {}", filename.display(), error); + continue; + }, + }; + let mut site = SiteConfig::from_file(file).await; + site.name = filename.file_stem().unwrap().to_string_lossy().to_string(); siteconfigs.push(site); } let used = siteconfigs.iter().map(|s| s.ca.clone()).collect::>(); @@ -174,7 +181,13 @@ async fn racme(flags: Arguments) -> Result<(), Error> { fn main() { log_init(); - let runtime = tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap(); + let runtime = match tokio::runtime::Builder::new_current_thread().enable_all().build() { + Ok(runtime) => runtime, + Err(error) => { + error!("Could not initialize Tokio runtime: {error}"); + exit(2) + }, + }; let result = runtime.block_on(racme(Arguments::parse())); runtime.shutdown_timeout(Duration::from_secs(1)); if let Err(error) = result { diff --git a/src/process.rs b/src/process.rs index 2bc821a..256f92c 100644 --- a/src/process.rs +++ b/src/process.rs @@ -311,7 +311,17 @@ pub async fn site(args: ProcessorArgs<'_>) { error!("Failed to complete the order: check the logs for more information"); return; } - let certs = order.certificate().await.unwrap().unwrap(); + let certs = match order.certificate().await { + Err(error) => { + error!("Failed to retrieve the certificates: {error}"); + return; + }, + Ok(None) => { + error!("The list of Certificate is Empty"); + return; + }, + Ok(Some(certs)) => certs, + }; debug!("Received {} certificates.", certs.len()); let mut pubkey_file = match_error!(FILE_MODE_WRITE.open(pubkey_filename).await=>Err(error)-> "Failed to open the file for the publickey: {error}"); match_error!(pubkey_file.write_all(&certs[0].to_pem().unwrap()).await=>Err(error)-> "Failed to write the publickey: {error}");