Initialize certificate for a specific domain
(&self, domain: &str)
| 61 | |
| 62 | /// Initialize certificate for a specific domain |
| 63 | pub async fn init_domain(&self, domain: &str) -> Result<()> { |
| 64 | // First, try to load from KvStore (synced from other nodes) |
| 65 | if let Some(cert_data) = self.kv_store.get_cert_data(domain) { |
| 66 | let now = now_secs(); |
| 67 | if cert_data.not_after > now { |
| 68 | info!( |
| 69 | domain, |
| 70 | "loaded from KvStore (issued by node {}, expires in {} days)", |
| 71 | cert_data.issued_by, |
| 72 | (cert_data.not_after - now) / 86400 |
| 73 | ); |
| 74 | self.cert_resolver.update_cert(domain, &cert_data)?; |
| 75 | return Ok(()); |
| 76 | } |
| 77 | info!(domain, "KvStore certificate expired, will request new one"); |
| 78 | } |
| 79 | |
| 80 | // No valid cert, need to request new one |
| 81 | info!(domain, "no valid certificate found, requesting from ACME"); |
| 82 | self.request_new_cert(domain).await |
| 83 | } |
| 84 | |
| 85 | /// Try to renew all ZT-Domain certificates |
| 86 | pub async fn try_renew_all(&self) -> Result<()> { |
no test coverage detected