Skip to content

Commit 1d4a426

Browse files
killswtchffMathy
authored andcommitted
Challenge response null guard (#20)
* Added null guard in response to issue #18 * Removed .gitattributes * Renamed variables to avoid confusion
1 parent 161999e commit 1d4a426

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/FluffySpoon.AspNet.LetsEncrypt/LetsEncryptRenewalService.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,14 +263,19 @@ private async Task ValidateOrderAsync(string[] domains, IOrderContext order)
263263

264264
try
265265
{
266-
var challenges = await ValidateChallengesAsync(nonNullChallengeContexts);
266+
var challengeValidationResponses = await ValidateChallengesAsync(nonNullChallengeContexts);
267+
var nonNullChallengeValidationResponses = challengeValidationResponses.Where(x => x != null).ToArray();
267268

269+
if (challengeValidationResponses.Length > nonNullChallengeValidationResponses.Length)
270+
_logger.LogWarning("Some challenge responses were null.");
271+
268272
await _persistenceService.DeleteChallengesAsync(challengeDtos);
269273

270-
var challengeExceptions = challenges
274+
var challengeExceptions = nonNullChallengeValidationResponses
271275
.Where(x => x.Status == ChallengeStatus.Invalid)
272276
.Select(x => new Exception($"{x.Error.Type}: {x.Error.Detail} (challenge type {x.Type})"))
273277
.ToArray();
278+
274279
if (challengeExceptions.Length > 0)
275280
throw new OrderInvalidException(
276281
"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.",

0 commit comments

Comments
 (0)