Update a single certificate (creates new store with updated cert) This is an incremental update that preserves all existing certificates. Write operations are serialized to prevent lost updates.
(&self, domain: &str, data: &CertData)
| 165 | /// This is an incremental update that preserves all existing certificates. |
| 166 | /// Write operations are serialized to prevent lost updates. |
| 167 | pub fn update_cert(&self, domain: &str, data: &CertData) -> Result<()> { |
| 168 | let _guard = self |
| 169 | .write_lock |
| 170 | .lock() |
| 171 | .or_panic("failed to acquire write lock"); |
| 172 | |
| 173 | let old_store = self.get(); |
| 174 | |
| 175 | // Build new store with all existing certs plus the new/updated one |
| 176 | let mut builder = CertStoreBuilder::new(); |
| 177 | |
| 178 | // Copy existing certs (except the one we're replacing) |
| 179 | for existing_domain in old_store.list_domains() { |
| 180 | if existing_domain != domain { |
| 181 | if let Some(existing_data) = old_store.get_cert_data(&existing_domain) { |
| 182 | builder.add_cert(&existing_domain, existing_data)?; |
| 183 | } |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | // Add the new/updated cert |
| 188 | builder.add_cert(domain, data)?; |
| 189 | |
| 190 | // Atomically swap |
| 191 | self.set(Arc::new(builder.build())); |
| 192 | Ok(()) |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | impl Default for CertResolver { |
no test coverage detected