Skip to content

Commit 109b639

Browse files
DNS Updates
1 parent b4b098d commit 109b639

4 files changed

Lines changed: 48 additions & 13 deletions

File tree

AcmeCaPlugin/AcmeCaPlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ private async Task ProcessAuthorizations(AcmeClient acmeClient, OrderDetails ord
345345
throw new InvalidOperationException("Missing or invalid authorization list in order payload.");
346346
}
347347

348-
var dnsVerifier = new DnsVerificationHelper(_logger);
348+
var dnsVerifier = new DnsVerificationHelper(_logger, config.DnsVerificationServer);
349349
var pendingChallenges = new List<(Authorization authz, Challenge challenge, Dns01ChallengeValidationDetails validation)>();
350350

351351
// First pass: Create all DNS records

AcmeCaPlugin/AcmeCaPluginConfig.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,15 @@ public static Dictionary<string, PropertyConfigInfo> GetPluginAnnotations()
202202
Hidden = true,
203203
DefaultValue = "",
204204
Type = "Secret"
205+
},
206+
207+
// DNS Verification Settings
208+
["DnsVerificationServer"] = new PropertyConfigInfo()
209+
{
210+
Comments = "DNS server to use for verifying TXT record propagation. For private/local DNS zones, set this to your authoritative DNS server IP (e.g., 10.3.10.37). Leave empty to use public DNS servers (Google, Cloudflare, etc.).",
211+
Hidden = false,
212+
DefaultValue = "",
213+
Type = "String"
205214
}
206215

207216
};

AcmeCaPlugin/AcmeClientConfig.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,8 @@ public class AcmeClientConfig
4848
public string WindowsDns_Username { get; set; } = null;
4949
public string WindowsDns_Password { get; set; } = null;
5050

51+
// DNS Verification Settings
52+
public string DnsVerificationServer { get; set; } = null;
53+
5154
}
5255
}

AcmeCaPlugin/Clients/DNS/DnsVerificationHelper.cs

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,51 @@ public class DnsVerificationHelper
1515
{
1616
private readonly ILogger _logger;
1717
private readonly List<IPAddress> _dnsServers;
18+
private readonly bool _usePrivateDns;
1819
private const int MaxVerificationAttempts = 3;
1920
private const int VerificationDelaySeconds = 10;
2021

21-
public DnsVerificationHelper(ILogger logger)
22+
/// <summary>
23+
/// Creates a DNS verification helper.
24+
/// </summary>
25+
/// <param name="logger">Logger instance</param>
26+
/// <param name="verificationServer">Optional DNS server IP for verification.
27+
/// For private/local zones (e.g., .local), specify your authoritative DNS server.
28+
/// Leave null/empty to use public DNS servers.</param>
29+
public DnsVerificationHelper(ILogger logger, string verificationServer = null)
2230
{
2331
_logger = logger;
32+
_dnsServers = new List<IPAddress>();
2433

25-
// Use multiple public DNS servers for verification
26-
_dnsServers = new List<IPAddress>
34+
// Check if a private DNS server was specified
35+
if (!string.IsNullOrWhiteSpace(verificationServer) && IPAddress.TryParse(verificationServer, out var privateServer))
36+
{
37+
_usePrivateDns = true;
38+
_dnsServers.Add(privateServer);
39+
_logger.LogInformation("DNS verification will use private DNS server: {Server}", verificationServer);
40+
}
41+
else
2742
{
28-
IPAddress.Parse("8.8.8.8"), // Google Primary
29-
IPAddress.Parse("8.8.4.4"), // Google Secondary
30-
IPAddress.Parse("1.1.1.1"), // Cloudflare Primary
31-
IPAddress.Parse("1.0.0.1"), // Cloudflare Secondary
32-
IPAddress.Parse("208.67.222.222"), // OpenDNS
33-
IPAddress.Parse("9.9.9.9") // Quad9
34-
};
43+
_usePrivateDns = false;
44+
// Use multiple public DNS servers for verification
45+
_dnsServers = new List<IPAddress>
46+
{
47+
IPAddress.Parse("8.8.8.8"), // Google Primary
48+
IPAddress.Parse("8.8.4.4"), // Google Secondary
49+
IPAddress.Parse("1.1.1.1"), // Cloudflare Primary
50+
IPAddress.Parse("1.0.0.1"), // Cloudflare Secondary
51+
IPAddress.Parse("208.67.222.222"), // OpenDNS
52+
IPAddress.Parse("9.9.9.9") // Quad9
53+
};
54+
}
3555
}
3656

3757
/// <summary>
3858
/// Waits for DNS TXT record to propagate across multiple DNS servers
3959
/// </summary>
4060
/// <param name="recordName">DNS record name (e.g., _acme-challenge.example.com)</param>
4161
/// <param name="expectedValue">Expected TXT record value</param>
42-
/// <param name="minimumServers">Minimum number of DNS servers that must see the record</param>
62+
/// <param name="minimumServers">Minimum number of DNS servers that must see the record (ignored for private DNS)</param>
4363
/// <returns>True if record propagated successfully</returns>
4464
public async Task<bool> WaitForDnsPropagationAsync(
4565
string recordName,
@@ -48,6 +68,9 @@ public async Task<bool> WaitForDnsPropagationAsync(
4868
{
4969
_logger.LogInformation("Waiting for DNS propagation of {RecordName}", recordName);
5070

71+
// For private DNS, only require 1 server (the authoritative server)
72+
var requiredServers = _usePrivateDns ? 1 : minimumServers;
73+
5174
for (int attempt = 1; attempt <= MaxVerificationAttempts; attempt++)
5275
{
5376
var successCount = 0;
@@ -79,7 +102,7 @@ public async Task<bool> WaitForDnsPropagationAsync(
79102
_logger.LogDebug("DNS verification attempt {Attempt}/{MaxAttempts}: {SuccessCount}/{TotalServers} servers confirmed record. Results: {Results}",
80103
attempt, MaxVerificationAttempts, successCount, _dnsServers.Count, string.Join(", ", results));
81104

82-
if (successCount >= minimumServers)
105+
if (successCount >= requiredServers)
83106
{
84107
_logger.LogInformation("DNS record propagated successfully! {SuccessCount}/{TotalServers} servers confirmed record after {Attempt} attempts",
85108
successCount, _dnsServers.Count, attempt);

0 commit comments

Comments
 (0)