diff options
author | Wouter Tinus <win.acme.simple@gmail.com> | 2020-07-17 10:14:39 +0200 |
---|---|---|
committer | Wouter Tinus <win.acme.simple@gmail.com> | 2020-07-17 10:14:39 +0200 |
commit | 1151855950b6def076a1be2f3d9d0db21f1d236c (patch) | |
tree | dcddd3374aaf08bf33426f9b3eb1364958b36f49 /src | |
parent | 8193202263ad9188db30bb5ee2d7b7dd4a1becfd (diff) | |
download | letsencrypt-win-simple-1151855950b6def076a1be2f3d9d0db21f1d236c.zip letsencrypt-win-simple-1151855950b6def076a1be2f3d9d0db21f1d236c.tar.gz letsencrypt-win-simple-1151855950b6def076a1be2f3d9d0db21f1d236c.tar.bz2 |
do not crash of failed acme-dns validation check
Diffstat (limited to 'src')
-rw-r--r-- | src/main.lib/Clients/AcmeDnsClient.cs | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/src/main.lib/Clients/AcmeDnsClient.cs b/src/main.lib/Clients/AcmeDnsClient.cs index fb6cd0d..8c885f6 100644 --- a/src/main.lib/Clients/AcmeDnsClient.cs +++ b/src/main.lib/Clients/AcmeDnsClient.cs @@ -112,7 +112,7 @@ namespace PKISharp.WACS.Clients } else if (interactive && _input != null) { - if (!await _input.PromptYesNo("Unable to verify acme-dns configuration, press 'Y' or <Enter> to retry, or 'N' to skip this step.", true)) + if (!await _input.PromptYesNo("Press 'Y' or <Enter> to retry, or 'N' to skip this step.", true)) { _log.Warning("Verification of acme-dns configuration skipped."); return true; @@ -132,36 +132,44 @@ namespace PKISharp.WACS.Clients /// <param name="cname"></param> /// <returns></returns> private async Task<bool> VerifyCname(string domain, string expected, int round) - { - var authority = await _dnsClient.GetAuthority(domain, round, false); - var result = authority.Nameservers.ToList(); - _log.Debug("Configuration will now be checked at name servers: {address}", - string.Join(", ", result.Select(x => x.IpAddress))); + {
+ try
+ {
+ var authority = await _dnsClient.GetAuthority(domain, round, false); + var result = authority.Nameservers.ToList(); + _log.Debug("Configuration will now be checked at name servers: {address}", + string.Join(", ", result.Select(x => x.IpAddress))); - // Parallel queries - var answers = await Task.WhenAll(result.Select(client => client.GetCname($"_acme-challenge.{domain}"))); + // Parallel queries + var answers = await Task.WhenAll(result.Select(client => client.GetCname($"_acme-challenge.{domain}"))); - // Loop through results - for (var i = 0; i < result.Count(); i++) - { - var currentClient = result[i]; - var currentResult = answers[i]; - if (string.Equals(expected, currentResult, StringComparison.CurrentCultureIgnoreCase)) - { - _log.Verbose("Verification of CNAME record successful at server {server}", currentClient.IpAddress); - } - else + // Loop through results + for (var i = 0; i < result.Count(); i++) { - _log.Warning("Verification failed, {domain} found value {found} but expected {expected} at server {server}", - $"_acme-challenge.{domain}", - currentResult ?? "(null)", - expected, - currentClient.IpAddress); - return false; + var currentClient = result[i]; + var currentResult = answers[i]; + if (string.Equals(expected, currentResult, StringComparison.CurrentCultureIgnoreCase)) + { + _log.Verbose("Verification of CNAME record successful at server {server}", currentClient.IpAddress); + } + else + { + _log.Warning("Verification failed, {domain} found value {found} but expected {expected} at server {server}", + $"_acme-challenge.{domain}", + currentResult ?? "(null)", + expected, + currentClient.IpAddress); + return false; + } } + _log.Information("Verification of acme-dns configuration succesful."); + return true;
+ }
+ catch (Exception ex)
+ {
+ _log.Error(ex, "Unable to verify acme-dns configuration.");
+ return false;
} - _log.Information("Verification of acme-dns configuration succesful."); - return true; } private string FileForDomain(string domain) => Path.Combine(_dnsConfigPath, $"{domain.CleanPath()}.json"); |