Skip to content

Commit 50f3e6a

Browse files
committed
fix(certbot): propagate authorization lookup failures
1 parent ddafae0 commit 50f3e6a

1 file changed

Lines changed: 13 additions & 22 deletions

File tree

dstack/certbot/src/acme_client.rs

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -627,13 +627,13 @@ impl AcmeClient {
627627
}
628628
// Something went wrong
629629
OrderStatus::Invalid => {
630-
let error = find_error(&mut order).await.unwrap_or(Problem {
631-
r#type: None,
632-
detail: None,
633-
status: None,
634-
subproblems: Vec::new(),
635-
});
636-
bail!("order is invalid: {error}");
630+
let error = find_error(&mut order).await.context(
631+
"order is invalid and its authorization error could not be retrieved",
632+
)?;
633+
match error {
634+
Some(error) => bail!("order is invalid: {error}"),
635+
None => bail!("order is invalid without error details"),
636+
}
637637
}
638638
}
639639
}
@@ -662,29 +662,21 @@ fn challenge_domain(identifier: &AuthorizedIdentifier<'_>) -> Result<String> {
662662
Ok(format!("_acme-challenge.{name}"))
663663
}
664664

665-
async fn find_error(order: &mut Order) -> Option<Problem> {
665+
async fn find_error(order: &mut Order) -> Result<Option<Problem>> {
666666
if let Some(error) = order.state().error.as_ref() {
667-
return Some(error.clone());
667+
return Ok(Some(error.clone()));
668668
}
669669
let mut authorizations = order.authorizations();
670670
while let Some(result) = authorizations.next().await {
671-
let authz = match result {
672-
Ok(authz) => authz,
673-
Err(err) => {
674-
// Stop rather than skip: the stream fetches authorizations in order, and a
675-
// failure here means we cannot see the rest either. Say so, so that the
676-
// caller's "order is invalid" message is not silently missing its cause.
677-
warn!("failed to fetch authorization while looking for the order error: {err}");
678-
break;
679-
}
680-
};
671+
let authz =
672+
result.context("failed to fetch authorization while looking for the order error")?;
681673
for challenge in &authz.challenges {
682674
if let Some(error) = &challenge.error {
683-
return Some(error.clone());
675+
return Ok(Some(error.clone()));
684676
}
685677
}
686678
}
687-
None
679+
Ok(None)
688680
}
689681

690682
/// The resolver from `/etc/resolv.conf`, used to find nameservers and as the
@@ -930,4 +922,3 @@ mod challenge_domain_tests {
930922
assert!(challenge_domain(&ip.authorized(false)).is_err());
931923
}
932924
}
933-

0 commit comments

Comments
 (0)