Skip to content

Commit a969d0b

Browse files
committed
Add error message, when dns-persist-01 cannot be created
1 parent db32a90 commit a969d0b

4 files changed

Lines changed: 19 additions & 2 deletions

File tree

src/ACMEServer.ADCS/ACMEServer.ADCS.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFrameworks>net8.0-windows;net10.0-windows</TargetFrameworks>
55
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
66
<PlatformTarget>x64</PlatformTarget>
7-
<InformationalVersion>3.1.0-beta5</InformationalVersion>
7+
<InformationalVersion>3.1.0-beta7</InformationalVersion>
88

99
<Nullable>enable</Nullable>
1010
<ImplicitUsings>enable</ImplicitUsings>

src/ACMEServer.Abstractions/LogMessages.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ public static partial class LogMessages
3333
Message = "No challenge types available for identifier {Identifier} and its metadata restrictions {AllowedChallengeTypes}")]
3434
public static partial void NoChallengeTypesAvailable(this ILogger logger, Identifier identifier, string allowedChallengeTypes);
3535

36+
[LoggerMessage(
37+
EventId = 1002,
38+
Level = LogLevel.Warning,
39+
Message = "CAA identities are not configured. Cannot create dns-persist-01 challenge.")]
40+
public static partial void CAAIdentitiesNotConfigured(this ILogger logger);
41+
3642
#endregion
3743

3844
#region CsrValidator (1020-1049)

src/ACMEServer/Configuration/ACMEServerOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class ACMEServerOptions
77

88
public string? CanonicalHostname { get; set; }
99

10-
public string[] CAAIdentities { get; set; } = [];
10+
public string[]? CAAIdentities { get; set; }
1111

1212
public string? WebsiteUrl { get; set; }
1313

src/ACMEServer/Services/DefaultAuthorizationFactory.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ public void CreateAuthorizations(Order order, Dictionary<Identifier, string[]> c
5555
}
5656

5757
CreateChallenges(authorization, allowedChallengeTypes);
58+
59+
if (authorization.Challenges.Count == 0)
60+
{
61+
_logger.NoChallengeTypesAvailable(authorization.Identifier, string.Join(",", allowedChallengeTypes));
62+
throw AcmeErrors.NoChallengeTypeAvailable(authorization.Identifier, authorization.Order.Profile).AsException();
63+
}
5864
}
5965
}
6066

@@ -76,6 +82,11 @@ private void CreateChallenges(Authorization authorization, List<string> allowedC
7682
else if (challengeType == ChallengeTypes.DnsPersist01)
7783
{
7884
var accountUri = _linkGenerator.GetAccount(accountId: authorization.Order.AccountId);
85+
if ((_serverOptions.Value.CAAIdentities?.Length ?? 0) == 0)
86+
{
87+
_logger.CAAIdentitiesNotConfigured();
88+
continue;
89+
}
7990
_ = new DnsPersistChallenge(authorization, accountUri, _serverOptions.Value.CAAIdentities);
8091
}
8192
else if (ChallengeTypes.TokenChallenges.Contains(challengeType)) {

0 commit comments

Comments
 (0)