Skip to content

Commit 19ac129

Browse files
zigszigsdkffMathy
authored andcommitted
Logic fix for changed external behavour (#21)
* ValidateOrderAsync Exception info null guard * Log OrderInvalidException before throwing it * bugfix: One valid challenge is enough don't wait for all to resolve. Issue discussed in #20 * Remove trace logs
1 parent 1d4a426 commit 19ac129

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/FluffySpoon.AspNet.LetsEncrypt/LetsEncryptRenewalService.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.IO;
43
using System.Linq;
54
using System.Security.Cryptography;
65
using System.Security.Cryptography.X509Certificates;
@@ -273,31 +272,32 @@ private async Task ValidateOrderAsync(string[] domains, IOrderContext order)
273272

274273
var challengeExceptions = nonNullChallengeValidationResponses
275274
.Where(x => x.Status == ChallengeStatus.Invalid)
276-
.Select(x => new Exception($"{x.Error.Type}: {x.Error.Detail} (challenge type {x.Type})"))
275+
.Select(x => new Exception($"{x.Error?.Type ?? "errortype null"}: {x.Error?.Detail ?? "null errordetails"} (challenge type {x.Type ?? "null"})"))
277276
.ToArray();
278277

279-
if (challengeExceptions.Length > 0)
278+
if (challengeExceptions.Length > 0)
280279
throw new OrderInvalidException(
281280
"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.",
282281
new AggregateException(challengeExceptions));
282+
283283
}
284284
finally
285285
{
286286
await _persistenceService.DeleteChallengesAsync(challengeDtos);
287287
}
288288
}
289289

290-
private static async Task<Challenge[]> ValidateChallengesAsync(IEnumerable<IChallengeContext> challengeContexts)
290+
private async Task<Challenge[]> ValidateChallengesAsync(IEnumerable<IChallengeContext> challengeContexts)
291291
{
292292
var challenges = await Task.WhenAll(
293293
challengeContexts.Select(x => x.Validate()));
294294

295295
while (true)
296296
{
297-
if (!challenges.Any(x => x.Status == ChallengeStatus.Pending || x.Status == ChallengeStatus.Processing))
297+
if (challenges.Any(x => x.Status == ChallengeStatus.Valid) || challenges.All(x => x.Status == ChallengeStatus.Invalid))
298298
break;
299-
300-
await Task.Delay(1000);
299+
300+
await Task.Delay(1000);
301301
challenges = await Task.WhenAll(challengeContexts.Select(x => x.Resource()));
302302
}
303303

0 commit comments

Comments
 (0)