Skip to content

Commit

Permalink
Prevent retry when remainingChallenges is empty (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
n0cloud authored Feb 2, 2022
1 parent 396e7d9 commit d2f4c2f
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,21 +517,33 @@ func (c *Client) pollAuthorization(ctx context.Context, account acme.Account, au

failedChallengeTypes.rememberFailedChallenge(authz)

switch problem.Type {
case acme.ProblemTypeConnection,
acme.ProblemTypeDNS,
acme.ProblemTypeServerInternal,
acme.ProblemTypeUnauthorized,
acme.ProblemTypeTLS:
// this error might be recoverable with another challenge type
return retryableErr{err}
if c.countAvailableChallenges(authz) > 0 {
switch problem.Type {
case acme.ProblemTypeConnection,
acme.ProblemTypeDNS,
acme.ProblemTypeServerInternal,
acme.ProblemTypeUnauthorized,
acme.ProblemTypeTLS:
// this error might be recoverable with another challenge type
return retryableErr{err}
}
}
}
return fmt.Errorf("[%s] %w", authz.Authorization.IdentifierValue(), err)
}
return nil
}

func (c *Client) countAvailableChallenges(authz *authzState) int {
count := 0
for _, remainingChal := range authz.remainingChallenges {
if _, ok := c.ChallengeSolvers[remainingChal.Type]; ok {
count++
}
}
return count
}

func (c *Client) enabledChallengeTypes() []string {
enabledChallenges := make([]string, 0, len(c.ChallengeSolvers))
for name, val := range c.ChallengeSolvers {
Expand Down

0 comments on commit d2f4c2f

Please sign in to comment.