mirror of
https://github.com/daywalker90/cln-nip47.git
synced 2026-08-13 12:33:43 +02:00
wait for hold certs to be generated
This commit is contained in:
parent
c956338bcd
commit
5c5f49de29
1 changed files with 17 additions and 0 deletions
17
src/main.rs
17
src/main.rs
|
|
@ -268,6 +268,14 @@ async fn check_hold_support(plugin: Plugin<PluginState>) -> 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<PluginState>) -> 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)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue