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

Method authorize

certbot/src/acme_client.rs:314–359  ·  view source on GitHub ↗
(&self, order: &mut Order, challenges: &mut Vec<Challenge>)

Source from the content-addressed store, hash-verified

312
313impl AcmeClient {
314 async fn authorize(&self, order: &mut Order, challenges: &mut Vec<Challenge>) -> Result<()> {
315 let authorizations = order
316 .authorizations()
317 .await
318 .context("failed to get authorizations")?;
319 for authz in &authorizations {
320 match authz.status {
321 AuthorizationStatus::Pending => {}
322 AuthorizationStatus::Valid => continue,
323 _ => bail!("unsupported authorization status: {:?}", authz.status),
324 }
325
326 let challenge = authz
327 .challenges
328 .iter()
329 .find(|c| c.r#type == ChallengeType::Dns01)
330 .context("no dns01 challenge found")?;
331
332 let Identifier::Dns(identifier) = &authz.identifier;
333
334 let dns_value = order.key_authorization(challenge).dns_value();
335 debug!("creating dns record for {identifier}");
336 let acme_domain = format!("_acme-challenge.{identifier}");
337 debug!("removing existing TXT record for {acme_domain}");
338 self.dns01_client
339 .remove_txt_records(&acme_domain)
340 .await
341 .context("failed to remove existing dns record")?;
342 debug!(
343 "creating TXT record for {acme_domain} with TTL {}s",
344 self.dns_txt_ttl
345 );
346 let id = self
347 .dns01_client
348 .add_txt_record(&acme_domain, &dns_value, self.dns_txt_ttl)
349 .await
350 .context("failed to create dns record")?;
351 challenges.push(Challenge {
352 id,
353 acme_domain,
354 url: challenge.url.clone(),
355 dns_value,
356 });
357 }
358 Ok(())
359 }
360
361 /// Self check the TXT records for the given challenges.
362 async fn check_dns(&self, challenges: &[Challenge]) -> Result<()> {

Callers 1

Calls 3

add_txt_recordMethod · 0.80
cloneMethod · 0.80
remove_txt_recordsMethod · 0.45

Tested by

no test coverage detected