Skip to content

Commit

Permalink
Challenge response null guard (#20)
Browse files Browse the repository at this point in the history
* Added null guard in response to issue #18

* Removed .gitattributes

* Renamed variables to avoid confusion
  • Loading branch information
killswtch authored and ffMathy committed Nov 27, 2019
1 parent 161999e commit 1d4a426
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,19 @@ private async Task ValidateOrderAsync(string[] domains, IOrderContext order)

try
{
var challenges = await ValidateChallengesAsync(nonNullChallengeContexts);
var challengeValidationResponses = await ValidateChallengesAsync(nonNullChallengeContexts);
var nonNullChallengeValidationResponses = challengeValidationResponses.Where(x => x != null).ToArray();

if (challengeValidationResponses.Length > nonNullChallengeValidationResponses.Length)
_logger.LogWarning("Some challenge responses were null.");

await _persistenceService.DeleteChallengesAsync(challengeDtos);

var challengeExceptions = challenges
var challengeExceptions = nonNullChallengeValidationResponses
.Where(x => x.Status == ChallengeStatus.Invalid)
.Select(x => new Exception($"{x.Error.Type}: {x.Error.Detail} (challenge type {x.Type})"))
.ToArray();

if (challengeExceptions.Length > 0)
throw new OrderInvalidException(
"One or more LetsEncrypt orders were invalid. Make sure that LetsEncrypt can contact the domain you are trying to request an SSL certificate for, in order to verify it.",
Expand Down

0 comments on commit 1d4a426

Please sign in to comment.