From 5c5f49de294a2b8b0c91840a0771a225b49cac20 Mon Sep 17 00:00:00 2001 From: daywalker90 <8257956+daywalker90@users.noreply.github.com> Date: Mon, 5 Jan 2026 14:49:33 +0100 Subject: [PATCH] wait for hold certs to be generated --- src/main.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main.rs b/src/main.rs index 957f9c8..59e5eed 100644 --- a/src/main.rs +++ b/src/main.rs @@ -268,6 +268,14 @@ async fn check_hold_support(plugin: Plugin) -> Result<(), anyhow::E cert_dir.to_str().unwrap() ); + let max_retries = 10; + let mut retries = 0; + while retries < max_retries && !do_certificates_exist(&cert_dir) { + log::debug!("Hold certificates incomplete. Waiting..."); + time::sleep(Duration::from_millis(500)).await; + retries += 1; + } + let ca_cert = tokio::fs::read(cert_dir.join("ca.pem")).await?; let client_cert = tokio::fs::read(cert_dir.join("client.pem")).await?; let client_key = tokio::fs::read(cert_dir.join("client-key.pem")).await?; @@ -289,3 +297,12 @@ async fn check_hold_support(plugin: Plugin) -> Result<(), anyhow::E Ok(()) } + +fn do_certificates_exist(cert_dir: &Path) -> bool { + let required_files = ["client.pem", "client-key.pem", "ca.pem"]; + + required_files.iter().all(|file| { + let path = cert_dir.join(file); + path.exists() && path.metadata().map(|m| m.len() > 0).unwrap_or(false) + }) +}