MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / update_cert

Method update_cert

gateway/src/cert_store.rs:167–193  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
196impl Default for CertResolver {

Callers 4

init_domainMethod · 0.80
request_new_certMethod · 0.80
do_request_newMethod · 0.80
do_renewMethod · 0.80

Calls 7

list_domainsMethod · 0.80
add_certMethod · 0.80
setMethod · 0.80
lockMethod · 0.45
getMethod · 0.45
get_cert_dataMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected