Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for subdomain wildcards #103

Open
roddharris opened this issue Jun 1, 2020 · 29 comments
Open

Support for subdomain wildcards #103

roddharris opened this issue Jun 1, 2020 · 29 comments
Labels

Comments

@roddharris
Copy link

roddharris commented Jun 1, 2020

I'm running into this error when I run the web job in Azure:
Error: At least one name server must be configured.

The Parameter that is listed is: nameServers. I'm sure there is something wrong in my configuration but I'm not sure where I'm going wrong.

I have a dedicated Azure App Service for hosting the lets-encrypt-webapp-renewer web job. (All my stuff -- DNS zone, Web Apps, etc -- are in the same resource group and subscription). I have the following configured (I'm leaving out resource group, etc.)

letsencrypt:azureDnsZone: mydomain.com
letsencrypt:webApps: MyWebAppName
letsencrypt:MyWebAppName-hosts: *.mysubdomain.mydomain.com
letsencrypt:MyWebApp-azureDnsRelativeRecordSetName: mysubdomain

What am I doing wrong here? Also, the documentation seems to indicate that I can only obtain wildcard certs when using DNS Zone challenge. Does this mean I cannot obtain a certificate for my root domain -- mydomain.com?

@ohadschn
Copy link
Owner

ohadschn commented Jun 2, 2020

  1. Could you share the full execution log which should include the full config and the full exception including stack trace (feel free to scrub out PII)?
  2. azureDnsZone should be azureDnsZoneName
  3. You are correct, root/naked/apex domain is not supported using wildcard/DNS. However you can use a dedicated group to issue an additional cert for the root domain (using the HTTP challenge): https://github.com/ohadschn/letsencrypt-webapp-renewer#multiple-certificates-for-a-single-site

@ohadschn
Copy link
Owner

ohadschn commented Jun 2, 2020

  1. letsencrypt:MyWebApp-azureDnsRelativeRecordSetName should be letsencrypt:MyWebAppName-azureDnsRelativeRecordSetName

@roddharris
Copy link
Author

roddharris commented Jun 2, 2020

Here is the full log. Anything I've "scrubbed" I've enclosed in ** ** (i.e. scrubbedName).

[06/01/2020 14:03:09 > f15b3d: SYS INFO] Status changed to Initializing
[06/01/2020 14:03:13 > f15b3d: SYS INFO] Run script 'AzureLetsEncryptRenewer.exe' with script host - 'WindowsScriptHost'
[06/01/2020 14:03:13 > f15b3d: SYS INFO] Status changed to Running
[06/01/2020 14:03:16 > f15b3d: INFO] AzureLetsEncryptRenewer.exe Information: 0 : Web App SSL renewal job (letsencrypt) started
[06/01/2020 14:03:16 > f15b3d: INFO] AzureLetsEncryptRenewer.exe Information: 0 : Parsing Web Apps for SSL renewal from WebJob/site configuration...
[06/01/2020 14:03:16 > f15b3d: INFO] AzureLetsEncryptRenewer.exe Information: 0 : Parsed web apps for SSL renewal: EligibilityTracker
[06/01/2020 14:03:16 > f15b3d: INFO] AzureLetsEncryptRenewer.exe Information: 0 : Parsed shared parameters: WebAppEnvironment: TenantId: **tenantname**.onmicrosoft.com, SubscriptionId: **subid**, ResourceGroup: **rg**, ClientId: **clientid**, Email: **email**, ServicePlanResourceGroup: , AzureDnsEnvironment: TenantId: , SubscriptionId: , ResourceGroup: , ClientId: , AzureDnsZoneName: **mydomain**.com, AzureDnsRelativeRecordSetName: , UseIpBasedSsl: , RsaKeyLength: , AcmeBaseUri: , WebRootPath: , RenewXNumberOfDaysBeforeExpiration: , AuthenticationUri: , AzureTokenAudience: , AzureManagementEndpoint: , AzureDefaultWebsiteDomainName: 
[06/01/2020 14:03:16 > f15b3d: INFO] AzureLetsEncryptRenewer.exe Information: 0 : Parsing SSL renewal parameters for web app 'EligibilityTracker'...
[06/01/2020 14:03:16 > f15b3d: INFO] AzureLetsEncryptRenewer.exe Information: 0 : Completed parsing of Web App SSL cert renewal information
[06/01/2020 14:03:16 > f15b3d: INFO] AzureLetsEncryptRenewer.exe Information: 0 : Adding / renewing SSL cert for 'EligibilityTracker' with parameters: WebApp: EligibilityTracker, Hosts: *.etracker.**mydomain**.com, *.etracker-test.**mydomain**.com, ServicePlanResourceGroup: , SiteSlotName: , GroupName: , WebAppEnvironmentParams: TenantId: **tenantname**.onmicrosoft.com, SubscriptionId: **subid**, ResourceGroup: **rg**, ClientId: **clientid**, AzureDnsEnvironmentParams: TenantId: **tenantname**.onmicrosoft.com, SubscriptionId: **subid**, ResourceGroup: EligibilityTracker, ClientId: **clientid**, AzureDnsZoneName: **mydomain**.com, AzureDnsRelativeRecordSetName: etracker, UseIpBasedSsl: False, RsaKeyLength: 2048, AcmeBaseUri: , WebRootPath: , RenewXNumberOfDaysBeforeExpiration: -1, AuthenticationUri: , AzureTokenAudience: , AzureManagementEndpoint: , AzureDefaultWebsiteDomainName: 
[06/01/2020 14:03:16 > f15b3d: INFO] AzureLetsEncryptRenewer.exe Information: 0 : Generating secure PFX password for 'EligibilityTracker'...
[06/01/2020 14:03:16 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.LetsencryptService Information: 0 : Certificate store didn't contain certificate or certificate was expired starting renewing
[06/01/2020 14:03:16 > f15b3d: INFO]     DateTime=2020-06-01T14:03:15.6600403Z
[06/01/2020 14:03:16 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.AcmeClient Information: 0 : Starting request DNS Challenge certificate for https://acme-v02.api.letsencrypt.org/directory and **email**
[06/01/2020 14:03:16 > f15b3d: INFO]     DateTime=2020-06-01T14:03:15.6898557Z
[06/01/2020 14:03:27 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.AcmeClient Information: 0 : Got DNS challenge token **tokenid**
[06/01/2020 14:03:27 > f15b3d: INFO]     DateTime=2020-06-01T14:03:27.4336601Z
[06/01/2020 14:03:28 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.DnsLookupService Information: 0 : Starting dns precheck validation for hostname: *.etracker.**mydomain**.com challenge: **tokenid** and timeout 60
[06/01/2020 14:03:28 > f15b3d: INFO]     DateTime=2020-06-01T14:03:28.6305451Z
[06/01/2020 14:03:28 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.LetsencryptService Error: 0 : Failed
[06/01/2020 14:03:28 > f15b3d: INFO]     DateTime=2020-06-01T14:03:28.8105184Z
[06/01/2020 14:03:28 > f15b3d: INFO] AzureLetsEncryptRenewer.exe Information: 0 : Evaluating exception: System.ArgumentException: At least one name server must be configured.
[06/01/2020 14:03:28 > f15b3d: INFO] Parameter name: nameServers
[06/01/2020 14:03:28 > f15b3d: INFO]    at DnsClient.LookupClient..ctor(NameServer[] nameServers)
[06/01/2020 14:03:28 > f15b3d: INFO]    at DnsClient.LookupClient..ctor(IPEndPoint[] nameServers)
[06/01/2020 14:03:28 > f15b3d: INFO]    at DnsClient.LookupClient..ctor(IPAddress[] nameServers)
[06/01/2020 14:03:28 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.DnsLookupService.GetDnsClient(String[] hostnames)
[06/01/2020 14:03:28 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.DnsLookupService.<Exists>d__2.MoveNext()
[06/01/2020 14:03:28 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:28 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:28 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:28 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
[06/01/2020 14:03:28 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.AcmeClient.<RequestDnsChallengeCertificate>d__5.MoveNext()
[06/01/2020 14:03:28 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:28 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:28 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:28 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
[06/01/2020 14:03:28 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.LetsencryptService.<Run>d__6.MoveNext()
[06/01/2020 14:03:28 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:28 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:28 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:28 > f15b3d: INFO]    at OhadSoft.AzureLetsEncrypt.Renewal.Management.RenewalManager.<RenewCore>d__7.MoveNext() in C:\projects\letsencrypt-webapp-renewer\src\OhadSoft.AzureLetsEncrypt.Renewal\Management\RenewalManager.cs:line 60
[06/01/2020 14:03:28 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:28 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:28 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:28 > f15b3d: INFO]    at OhadSoft.AzureLetsEncrypt.Renewal.WebJob.AppSettings.AppSettingsRenewer.<Renew>d__4.MoveNext() in C:\projects\letsencrypt-webapp-renewer\src\OhadSoft.AzureLetsEncrypt.Renewal.WebJob\AppSettings\AppSettingsRenewer.cs:line 34 (False)
[06/01/2020 14:03:28 > f15b3d: INFO] AzureLetsEncryptRenewer.exe Error: 0 : Encountered exception: System.ArgumentException: At least one name server must be configured.
[06/01/2020 14:03:28 > f15b3d: INFO] Parameter name: nameServers
[06/01/2020 14:03:28 > f15b3d: INFO]    at DnsClient.LookupClient..ctor(NameServer[] nameServers)
[06/01/2020 14:03:28 > f15b3d: INFO]    at DnsClient.LookupClient..ctor(IPEndPoint[] nameServers)
[06/01/2020 14:03:28 > f15b3d: INFO]    at DnsClient.LookupClient..ctor(IPAddress[] nameServers)
[06/01/2020 14:03:28 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.DnsLookupService.GetDnsClient(String[] hostnames)
[06/01/2020 14:03:28 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.DnsLookupService.<Exists>d__2.MoveNext()
[06/01/2020 14:03:28 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:28 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:28 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:28 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
[06/01/2020 14:03:28 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.AcmeClient.<RequestDnsChallengeCertificate>d__5.MoveNext()
[06/01/2020 14:03:28 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:28 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:28 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:28 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
[06/01/2020 14:03:28 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.LetsencryptService.<Run>d__6.MoveNext()
[06/01/2020 14:03:28 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:28 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:28 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:28 > f15b3d: INFO]    at OhadSoft.AzureLetsEncrypt.Renewal.Management.RenewalManager.<RenewCore>d__7.MoveNext() in C:\projects\letsencrypt-webapp-renewer\src\OhadSoft.AzureLetsEncrypt.Renewal\Management\RenewalManager.cs:line 60
[06/01/2020 14:03:28 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:28 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:28 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:28 > f15b3d: INFO]    at OhadSoft.AzureLetsEncrypt.Renewal.WebJob.AppSettings.AppSettingsRenewer.<Renew>d__4.MoveNext() in C:\projects\letsencrypt-webapp-renewer\src\OhadSoft.AzureLetsEncrypt.Renewal.WebJob\AppSettings\AppSettingsRenewer.cs:line 34
[06/01/2020 14:03:28 > f15b3d: INFO] AzureLetsEncryptRenewer.exe Information: 0 : Evaluating exception: System.AggregateException: Encountered exception(s) during cert renewal (and/or notification) ---> System.ArgumentException: At least one name server must be configured.
[06/01/2020 14:03:28 > f15b3d: INFO] Parameter name: nameServers
[06/01/2020 14:03:28 > f15b3d: INFO]    at DnsClient.LookupClient..ctor(NameServer[] nameServers)
[06/01/2020 14:03:29 > f15b3d: INFO]    at DnsClient.LookupClient..ctor(IPEndPoint[] nameServers)
[06/01/2020 14:03:29 > f15b3d: INFO]    at DnsClient.LookupClient..ctor(IPAddress[] nameServers)
[06/01/2020 14:03:29 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.DnsLookupService.GetDnsClient(String[] hostnames)
[06/01/2020 14:03:29 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.DnsLookupService.<Exists>d__2.MoveNext()
[06/01/2020 14:03:29 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
[06/01/2020 14:03:29 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.AcmeClient.<RequestDnsChallengeCertificate>d__5.MoveNext()
[06/01/2020 14:03:29 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
[06/01/2020 14:03:29 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.LetsencryptService.<Run>d__6.MoveNext()
[06/01/2020 14:03:29 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at OhadSoft.AzureLetsEncrypt.Renewal.Management.RenewalManager.<RenewCore>d__7.MoveNext() in C:\projects\letsencrypt-webapp-renewer\src\OhadSoft.AzureLetsEncrypt.Renewal\Management\RenewalManager.cs:line 60
[06/01/2020 14:03:29 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at OhadSoft.AzureLetsEncrypt.Renewal.WebJob.AppSettings.AppSettingsRenewer.<Renew>d__4.MoveNext() in C:\projects\letsencrypt-webapp-renewer\src\OhadSoft.AzureLetsEncrypt.Renewal.WebJob\AppSettings\AppSettingsRenewer.cs:line 34
[06/01/2020 14:03:29 > f15b3d: INFO]    --- End of inner exception stack trace ---
[06/01/2020 14:03:29 > f15b3d: INFO]    at OhadSoft.AzureLetsEncrypt.Renewal.WebJob.AppSettings.AppSettingsRenewer.<Renew>d__4.MoveNext() in C:\projects\letsencrypt-webapp-renewer\src\OhadSoft.AzureLetsEncrypt.Renewal.WebJob\AppSettings\AppSettingsRenewer.cs:line 46
[06/01/2020 14:03:29 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at OhadSoft.AzureLetsEncrypt.Renewal.WebJob.Program.WebJobMain(String webjobName) in C:\projects\letsencrypt-webapp-renewer\src\OhadSoft.AzureLetsEncrypt.Renewal.WebJob\Program.cs:line 66
[06/01/2020 14:03:29 > f15b3d: INFO] ---> (Inner Exception #0) System.ArgumentException: At least one name server must be configured.
[06/01/2020 14:03:29 > f15b3d: INFO] Parameter name: nameServers
[06/01/2020 14:03:29 > f15b3d: INFO]    at DnsClient.LookupClient..ctor(NameServer[] nameServers)
[06/01/2020 14:03:29 > f15b3d: INFO]    at DnsClient.LookupClient..ctor(IPEndPoint[] nameServers)
[06/01/2020 14:03:29 > f15b3d: INFO]    at DnsClient.LookupClient..ctor(IPAddress[] nameServers)
[06/01/2020 14:03:29 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.DnsLookupService.GetDnsClient(String[] hostnames)
[06/01/2020 14:03:29 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.DnsLookupService.<Exists>d__2.MoveNext()
[06/01/2020 14:03:29 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
[06/01/2020 14:03:29 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.AcmeClient.<RequestDnsChallengeCertificate>d__5.MoveNext()
[06/01/2020 14:03:29 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
[06/01/2020 14:03:29 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.LetsencryptService.<Run>d__6.MoveNext()
[06/01/2020 14:03:29 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at OhadSoft.AzureLetsEncrypt.Renewal.Management.RenewalManager.<RenewCore>d__7.MoveNext() in C:\projects\letsencrypt-webapp-renewer\src\OhadSoft.AzureLetsEncrypt.Renewal\Management\RenewalManager.cs:line 60
[06/01/2020 14:03:29 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at OhadSoft.AzureLetsEncrypt.Renewal.WebJob.AppSettings.AppSettingsRenewer.<Renew>d__4.MoveNext() in C:\projects\letsencrypt-webapp-renewer\src\OhadSoft.AzureLetsEncrypt.Renewal.WebJob\AppSettings\AppSettingsRenewer.cs:line 34<---
[06/01/2020 14:03:29 > f15b3d: INFO]  (False)
[06/01/2020 14:03:29 > f15b3d: INFO] AzureLetsEncryptRenewer.exe Error: 0 : Unexpected exception: System.AggregateException: Encountered exception(s) during cert renewal (and/or notification) ---> System.ArgumentException: At least one name server must be configured.
[06/01/2020 14:03:29 > f15b3d: INFO] Parameter name: nameServers
[06/01/2020 14:03:29 > f15b3d: INFO]    at DnsClient.LookupClient..ctor(NameServer[] nameServers)
[06/01/2020 14:03:29 > f15b3d: INFO]    at DnsClient.LookupClient..ctor(IPEndPoint[] nameServers)
[06/01/2020 14:03:29 > f15b3d: INFO]    at DnsClient.LookupClient..ctor(IPAddress[] nameServers)
[06/01/2020 14:03:29 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.DnsLookupService.GetDnsClient(String[] hostnames)
[06/01/2020 14:03:29 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.DnsLookupService.<Exists>d__2.MoveNext()
[06/01/2020 14:03:29 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
[06/01/2020 14:03:29 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.AcmeClient.<RequestDnsChallengeCertificate>d__5.MoveNext()
[06/01/2020 14:03:29 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
[06/01/2020 14:03:29 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.LetsencryptService.<Run>d__6.MoveNext()
[06/01/2020 14:03:29 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at OhadSoft.AzureLetsEncrypt.Renewal.Management.RenewalManager.<RenewCore>d__7.MoveNext() in C:\projects\letsencrypt-webapp-renewer\src\OhadSoft.AzureLetsEncrypt.Renewal\Management\RenewalManager.cs:line 60
[06/01/2020 14:03:29 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at OhadSoft.AzureLetsEncrypt.Renewal.WebJob.AppSettings.AppSettingsRenewer.<Renew>d__4.MoveNext() in C:\projects\letsencrypt-webapp-renewer\src\OhadSoft.AzureLetsEncrypt.Renewal.WebJob\AppSettings\AppSettingsRenewer.cs:line 34
[06/01/2020 14:03:29 > f15b3d: INFO]    --- End of inner exception stack trace ---
[06/01/2020 14:03:29 > f15b3d: INFO]    at OhadSoft.AzureLetsEncrypt.Renewal.WebJob.AppSettings.AppSettingsRenewer.<Renew>d__4.MoveNext() in C:\projects\letsencrypt-webapp-renewer\src\OhadSoft.AzureLetsEncrypt.Renewal.WebJob\AppSettings\AppSettingsRenewer.cs:line 46
[06/01/2020 14:03:29 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at OhadSoft.AzureLetsEncrypt.Renewal.WebJob.Program.WebJobMain(String webjobName) in C:\projects\letsencrypt-webapp-renewer\src\OhadSoft.AzureLetsEncrypt.Renewal.WebJob\Program.cs:line 66
[06/01/2020 14:03:29 > f15b3d: INFO] ---> (Inner Exception #0) System.ArgumentException: At least one name server must be configured.
[06/01/2020 14:03:29 > f15b3d: INFO] Parameter name: nameServers
[06/01/2020 14:03:29 > f15b3d: INFO]    at DnsClient.LookupClient..ctor(NameServer[] nameServers)
[06/01/2020 14:03:29 > f15b3d: ERR ] 
[06/01/2020 14:03:29 > f15b3d: INFO]    at DnsClient.LookupClient..ctor(IPEndPoint[] nameServers)
ception(s) during cert renewal (and/or notification) ---> System.ArgumentException: At least one name server must be configured.
[06/01/2020 14:03:29 > f15b3d: INFO]    at DnsClient.LookupClient..ctor(IPAddress[] nameServers)
[06/01/2020 14:03:29 > f15b3d: ERR ] Parameter name: nameServers
[06/01/2020 14:03:29 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.DnsLookupService.GetDnsClient(String[] hostnames)
[06/01/2020 14:03:29 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.DnsLookupService.<Exists>d__2.MoveNext()
[06/01/2020 14:03:29 > f15b3d: ERR ]    at DnsClient.LookupClient..ctor(IPEndPoint[] nameServers)
[06/01/2020 14:03:29 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:29 > f15b3d: ERR ]    at LetsEncrypt.Azure.Core.V2.DnsLookupService.GetDnsClient(String[] hostnames)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
[06/01/2020 14:03:29 > f15b3d: ERR ] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:29 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.AcmeClient.<RequestDnsChallengeCertificate>d__5.MoveNext()
[06/01/2020 14:03:29 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:29 > f15b3d: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:29 > f15b3d: ERR ]    at LetsEncrypt.Azure.Core.V2.AcmeClient.<RequestDnsChallengeCertificate>d__5.MoveNext()
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
 thrown ---
[06/01/2020 14:03:29 > f15b3d: INFO]    at LetsEncrypt.Azure.Core.V2.LetsencryptService.<Run>d__6.MoveNext()
[06/01/2020 14:03:29 > f15b3d: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
otification(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:29 > f15b3d: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:29 > f15b3d: ERR ] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:29 > f15b3d: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:29 > f15b3d: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at OhadSoft.AzureLetsEncrypt.Renewal.Management.RenewalManager.<RenewCore>d__7.MoveNext() in C:\projects\letsencrypt-webapp-renewer\src\OhadSoft.AzureLetsEncrypt.Renewal\Management\RenewalManager.cs:line 60
[06/01/2020 14:03:29 > f15b3d: ERR ] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:29 > f15b3d: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:29 > f15b3d: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:29 > f15b3d: ERR ]    at OhadSoft.AzureLetsEncrypt.Renewal.WebJob.AppSettings.AppSettingsRenewer.<Renew>d__4.MoveNext() in C:\projects\letsencrypt-webapp-renewer\src\OhadSoft.AzureLetsEncrypt.Renewal.WebJob\AppSettings\AppSettingsRenewer.cs:line 34
[06/01/2020 14:03:29 > f15b3d: ERR ]    --- End of inner exception stack trace ---
[06/01/2020 14:03:29 > f15b3d: INFO] --- End of stack trace from previous location where exception was thrown ---
<Renew>d__4.MoveNext() in C:\projects\letsencrypt-webapp-renewer\src\OhadSoft.AzureLetsEncrypt.Renewal.WebJob\AppSettings\AppSettingsRenewer.cs:line 46
[06/01/2020 14:03:29 > f15b3d: ERR ] --- End of stack trace from previous location where exception was thrown ---
[06/01/2020 14:03:29 > f15b3d: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:29 > f15b3d: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:29 > f15b3d: ERR ]    at OhadSoft.AzureLetsEncrypt.Renewal.WebJob.Program.WebJobMain(String webjobName) in C:\projects\letsencrypt-webapp-renewer\src\OhadSoft.AzureLetsEncrypt.Renewal.WebJob\Program.cs:line 71
[06/01/2020 14:03:29 > f15b3d: ERR ]    at OhadSoft.AzureLetsEncrypt.Renewal.WebJob.Program.Main(String[] args) in C:\projects\letsencrypt-webapp-renewer\src\OhadSoft.AzureLetsEncrypt.Renewal.WebJob\Program.cs:line 41
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[06/01/2020 14:03:29 > f15b3d: INFO]    at OhadSoft.AzureLetsEncrypt.Renewal.WebJob.AppSettings.AppSettingsRenewer.<Renew>d__4.MoveNext() in C:\projects\letsencrypt-webapp-renewer\src\OhadSoft.AzureLetsEncrypt.Renewal.WebJob\AppSettings\AppSettingsRenewer.cs:line 34<---
[06/01/2020 14:03:29 > f15b3d: INFO] 
[06/01/2020 14:03:29 > f15b3d: SYS INFO] Status changed to Failed
[06/01/2020 14:03:29 > f15b3d: SYS ERR ] Job failed due to exit code -532462766
  • Please let me know if I've scrubbed something that was necessary for debugging.

@roddharris
Copy link
Author

P.S. In regards to items 2 and 4, those were just typos when I posted. Those items are actually configured correctly in the App Service.

@ohadschn
Copy link
Owner

ohadschn commented Jun 8, 2020

I tracked down the exception to this line: https://github.com/sjkp/letsencrypt-azure/blob/master/src/LetsEncrypt.Azure.Core.V2/DnsLookupService.cs#L61

Basically you will see this if etracker.mydomain.com doesn't have any associated nameservers (for example, if it doesn't exist). You can debug it in a new project (or LINQPad) by adding the DnsClient NuGet (version 1.2) and calling a function like this with your non-wildacrd domain (so basically whatever you have configured without the leading *., in your case etracker.mydomain.com):

private static LookupClient GetDnsClient(params string[] hostnames)
{
  LookupClient generalClient = new LookupClient();
  LookupClient dnsClient = null;
  generalClient.UseCache = false;
  foreach (var hostname in hostnames)
  {
    var ns = generalClient.Query(hostname, QueryType.NS);
    if (!ns.Answers.NsRecords().Any()) throw new Exception(); // <== THIS IS THE KEY

    var ip = ns.Answers.NsRecords().Select(s => generalClient.GetHostEntry(s.NSDName.Value));

    dnsClient = new LookupClient(ip.SelectMany(i => i.AddressList).Where(s => s.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).ToArray());
    dnsClient.UseCache = false;

  }

  return dnsClient;
}

@roddharris
Copy link
Author

roddharris commented Jun 10, 2020

Thanks for looking into this; although, I'm a bit confused as to how to go about configuring this service for my situation. Here is what I have:

  • A DNS zone in Azure for mydomain.com.
  • An Azure App Service called EligibilityTracker that is multi-tenant -- so users need to access it with a URL like tenantname.etracker.mydomain.com.
  • CNAME entries in mydomain.com for *.etracker.mydomain.com and etracker.mydomain.com -- both of which point to my Azure App Service.

Now I need a certificate for etracker.mydomain.com,*.etracker.mydomain.com. How would I configure this for LetsEncrypt WebApp Renewer? My current settings are:

  • letsencrypt:azureDnsZoneName: mydomain.com
  • letsencrypt:webApps: EligibilityTracker
  • letsencrypt:EligibilityTracker-azureDnsRelativeRecordSetName: etracker
  • letsencrypt:EligibilityTracker-hosts: *.etracker.mydomain.com,etracker.mydomain.com

I'm wondering if maybe my use of letsencrypt:EligibilityTracker-azureDnsRelativeRecordSetName is causing the problem?

Update
I removed letsencrypt:EligibilityTracker-azureDnsRelativeRecordSetName and this error went away. I'm still having other errors related to my configuration -- but that seemed to be what was causing this issue.

Thanks for your help.

@ohadschn
Copy link
Owner

I'm afraid azureDnsRelativeRecordSetName is mandatory, and if you don't specify it, DNS challenge will not be used. To be honest I don't really know what it does, but I think the value you provided makes sense, or maybe try the default "@".

Anyway, I don't think the error you saw was related. Did you try executing the GetDnsClient method I provided above with your actual domain? That would be the easiest way to make sure etracker.mydomain.com has its nameservers configured correctly.

@roddharris
Copy link
Author

@ohadschn , So maybe I'm trying to do something that isn't supported.

I ran the above code. It ran fine when I did GetDnsClient("mydomain.com") but threw an exception when I tried GetDnsClient("mydomain.com","etracker.mydomain.com").

However, stepping through the code, I can see that the code IS finding the CNAME entry for etracker.mydomain.com (i.e. ns.Answers)

image

It just appears that the NSRecords() doesn't contain anything. So I'm a bit confused. What does my CNAME entry need in order to satisfy whatever NSRecords() is looking for and why is that necessary?

@ohadschn
Copy link
Owner

ohadschn commented Jun 11, 2020

You can find the implementation here - basically it's OfType<NsRecord>() so you are getting answers, but not nameserver (NS) answers.

I think I see what's going on. It looks like only naked domains get NS answers. Can you change your cert to *.mydomain.com? (I believe it will include *.etracker.mydomain.com)

@roddharris
Copy link
Author

Progress! So, I realized that i had two CNAME entries in my DNS Zone -- one for etracker.mydomain.com and the other for *.etracker.mydomain.com. I had both pointing to my app service URL. I changed etracker.mydomain.com to point to mydomain.com. This now passes the test code that you listed above.

I re-ran my web job and we definitely got much further. This time, it actually created my DNS challenge token in my DNS; however, it errors out trying to validate the dns challenge. Again, looking in my DNS, I can see that the _acme-challenge TXT entry was created in my DNS and the value is the same as what is referenced in the log.

I can see the following in the log:

[06/11/2020 17:38:31 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.LetsencryptService Information: 0 : Certificate store didn't contain certificate or certificate was expired starting renewing
[06/11/2020 17:38:31 > f15b3d: INFO]     DateTime=2020-06-11T17:38:31.6140101Z
[06/11/2020 17:38:31 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.AcmeClient Information: 0 : Starting request DNS Challenge certificate for https://acme-v02.api.letsencrypt.org/directory and myemail@mydomain.com
[06/11/2020 17:38:31 > f15b3d: INFO]     DateTime=2020-06-11T17:38:31.6261598Z
[06/11/2020 17:38:43 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.AcmeClient Information: 0 : Got DNS challenge token FThnBoKpm5neVuiYZY6y0_aDYA6t7DLTX0RY5lpl5XU
[06/11/2020 17:38:43 > f15b3d: INFO]     DateTime=2020-06-11T17:38:43.2898509Z
[06/11/2020 17:38:44 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.DnsLookupService Information: 0 : Starting dns precheck validation for hostname: *.etracker.mydomain.com challenge: FThnBoKpm5neVuiYZY6y0_aDYA6t7DLTX0RY5lpl5XU and timeout 60
[06/11/2020 17:38:44 > f15b3d: INFO]     DateTime=2020-06-11T17:38:44.8019898Z
[06/11/2020 17:38:44 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.DnsLookupService Information: 0 : Validating dns challenge exists on name server **ip address 1** (Udp: 512)
[06/11/2020 17:38:44 > f15b3d: INFO]     DateTime=2020-06-11T17:38:44.9894451Z
[06/11/2020 17:38:45 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.DnsLookupService Information: 0 : Challenge record was (null) should have been FThnBoKpm5neVuiYZY6y0_aDYA6t7DLTX0RY5lpl5XU, retrying again in 5 seconds
[06/11/2020 17:38:45 > f15b3d: INFO]     DateTime=2020-06-11T17:38:45.0051262Z
[06/11/2020 17:38:50 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.DnsLookupService Information: 0 : Challenge record was (null) should have been FThnBoKpm5neVuiYZY6y0_aDYA6t7DLTX0RY5lpl5XU, retrying again in 5 seconds
[06/11/2020 17:38:50 > f15b3d: INFO]     DateTime=2020-06-11T17:38:50.0141433Z
[06/11/2020 17:38:55 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.DnsLookupService Information: 0 : Challenge record was (null) should have been FThnBoKpm5neVuiYZY6y0_aDYA6t7DLTX0RY5lpl5XU, retrying again in 5 seconds
[06/11/2020 17:38:55 > f15b3d: INFO]     DateTime=2020-06-11T17:38:55.0305030Z
[06/11/2020 17:39:00 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.DnsLookupService Information: 0 : Challenge record was (null) should have been FThnBoKpm5neVuiYZY6y0_aDYA6t7DLTX0RY5lpl5XU, retrying again in 5 seconds
[06/11/2020 17:39:00 > f15b3d: INFO]     DateTime=2020-06-11T17:39:00.0332023Z
[06/11/2020 17:39:05 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.DnsLookupService Information: 0 : Challenge record was (null) should have been FThnBoKpm5neVuiYZY6y0_aDYA6t7DLTX0RY5lpl5XU, retrying again in 5 seconds
[06/11/2020 17:39:05 > f15b3d: INFO]     DateTime=2020-06-11T17:39:05.0553823Z
[06/11/2020 17:39:10 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.DnsLookupService Information: 0 : Challenge record was (null) should have been FThnBoKpm5neVuiYZY6y0_aDYA6t7DLTX0RY5lpl5XU, retrying again in 5 seconds
[06/11/2020 17:39:10 > f15b3d: INFO]     DateTime=2020-06-11T17:39:10.0572172Z
[06/11/2020 17:39:15 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.DnsLookupService Information: 0 : Challenge record was (null) should have been FThnBoKpm5neVuiYZY6y0_aDYA6t7DLTX0RY5lpl5XU, retrying again in 5 seconds
[06/11/2020 17:39:15 > f15b3d: INFO]     DateTime=2020-06-11T17:39:15.0736035Z
[06/11/2020 17:39:20 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.DnsLookupService Information: 0 : Challenge record was (null) should have been FThnBoKpm5neVuiYZY6y0_aDYA6t7DLTX0RY5lpl5XU, retrying again in 5 seconds
[06/11/2020 17:39:20 > f15b3d: INFO]     DateTime=2020-06-11T17:39:20.0828305Z
[06/11/2020 17:39:25 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.DnsLookupService Information: 0 : Challenge record was (null) should have been FThnBoKpm5neVuiYZY6y0_aDYA6t7DLTX0RY5lpl5XU, retrying again in 5 seconds
[06/11/2020 17:39:25 > f15b3d: INFO]     DateTime=2020-06-11T17:39:25.0893746Z
[06/11/2020 17:39:30 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.DnsLookupService Information: 0 : Challenge record was (null) should have been FThnBoKpm5neVuiYZY6y0_aDYA6t7DLTX0RY5lpl5XU, retrying again in 5 seconds
[06/11/2020 17:39:30 > f15b3d: INFO]     DateTime=2020-06-11T17:39:30.1775658Z
[06/11/2020 17:39:35 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.DnsLookupService Information: 0 : Challenge record was (null) should have been FThnBoKpm5neVuiYZY6y0_aDYA6t7DLTX0RY5lpl5XU, retrying again in 5 seconds
[06/11/2020 17:39:35 > f15b3d: INFO]     DateTime=2020-06-11T17:39:35.1859549Z
[06/11/2020 17:39:40 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.DnsLookupService Information: 0 : Challenge record was (null) should have been FThnBoKpm5neVuiYZY6y0_aDYA6t7DLTX0RY5lpl5XU, retrying again in 5 seconds
[06/11/2020 17:39:40 > f15b3d: INFO]     DateTime=2020-06-11T17:39:40.1984073Z
[06/11/2020 17:39:45 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.DnsLookupService Information: 0 : Validating dns challenge exists on name server **ip address 2** (Udp: 512)
[06/11/2020 17:39:45 > f15b3d: INFO]     DateTime=2020-06-11T17:39:45.2077456Z
[06/11/2020 17:39:45 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.DnsLookupService Information: 0 : Challenge record was (null) should have been FThnBoKpm5neVuiYZY6y0_aDYA6t7DLTX0RY5lpl5XU, retrying again in 5 seconds
[06/11/2020 17:39:45 > f15b3d: INFO]     DateTime=2020-06-11T17:39:45.2077456Z
[06/11/2020 17:39:50 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.DnsLookupService Information: 0 : Validating dns challenge exists on name server **ip address 3** (Udp: 512)
[06/11/2020 17:39:50 > f15b3d: INFO]     DateTime=2020-06-11T17:39:50.2169828Z
[06/11/2020 17:39:50 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.DnsLookupService Information: 0 : Challenge record was (null) should have been FThnBoKpm5neVuiYZY6y0_aDYA6t7DLTX0RY5lpl5XU, retrying again in 5 seconds
[06/11/2020 17:39:50 > f15b3d: INFO]     DateTime=2020-06-11T17:39:50.2169828Z
[06/11/2020 17:39:55 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.DnsLookupService Information: 0 : Validating dns challenge exists on name server **ip address 3** (Udp: 512)
[06/11/2020 17:39:55 > f15b3d: INFO]     DateTime=2020-06-11T17:39:55.2310490Z
[06/11/2020 17:39:55 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.DnsLookupService Information: 0 : Challenge record was (null) should have been FThnBoKpm5neVuiYZY6y0_aDYA6t7DLTX0RY5lpl5XU, retrying again in 5 seconds
[06/11/2020 17:39:55 > f15b3d: INFO]     DateTime=2020-06-11T17:39:55.2474948Z
[06/11/2020 17:40:00 > f15b3d: INFO] LetsEncrypt.Azure.Core.V2.LetsencryptService Error: 0 : Failed
[06/11/2020 17:40:00 > f15b3d: INFO]     DateTime=2020-06-11T17:40:00.2556424Z
[06/11/2020 17:40:00 > f15b3d: INFO] AzureLetsEncryptRenewer.exe Information: 0 : Evaluating exception: System.TimeoutException: Unable to validate that _acme-challenge was stored in txt _acme-challenge record after 60 seconds

@ohadschn
Copy link
Owner

ohadschn commented Jun 11, 2020

  1. Can you verify that in real-time? That is, that the _acme-challenge is there at some point in time before the last Challenge record was (null) log line?
  2. Can you try a *.mydomain.com certificate? I suspect that was the author's main use case

@ohadschn
Copy link
Owner

ohadschn commented Jun 11, 2020

Also, since you already know how to debug this, might as well debug the real thing:
https://github.com/sjkp/letsencrypt-azure/blob/dbdc477a88569f3fc63e1865c669923aacbf2d7a/src/LetsEncrypt.Azure.Core.V2/DnsLookupService.cs#L22

You can run that loop on your dev machine (just as you have the NS lookup code above) and see if you're getting the TXT DNS entries.

@ohadschn
Copy link
Owner

Specifically, you need to make sure the TXT record is named the way it's expecting it. In your case I believe that would be _acme-challenge.etracker.mydomain.com

@roddharris
Copy link
Author

In my case, it was named _acme-challenge -- maybe that's the problem.

@ohadschn
Copy link
Owner

ohadschn commented Jun 11, 2020

No that's not it, I just checked in my Azure DNS and it has that one too. I think this line:

var dnsRes = dnsClient.QueryServer(new[] { ns.Endpoint.Address }, $"_acme-challenge.{hostname}", QueryType.TXT);

Means that it looks for an _acme-challenge in the DNS records of the host {hostname}. But in your case {hostname} == etracker.mydomain.com and I suspect that will only work for {hostname} == mydomain.com. You can run that line locally to test this suspicion.

And again, if you use *.mydomain.com I'm betting it will work. Or maybe you can create a DNS zone for etracker.mydomain.com, but I'm not sure if you can.

@roddharris
Copy link
Author

@ohadschn - Looks like what I'm trying to do is not yet supported. However, it looks like someone has added a pull request to make it possible.

How quickly will you update your project to work with the updated letsencrypt-azure code once the approved?

@ohadschn
Copy link
Owner

I doubt I'll be the bottleneck - look at that PR, it's been open for more than a year...

@roddharris
Copy link
Author

roddharris commented Jun 12, 2020

Shoot - I didn't even notice the 2019 date. I guess my only option at this point then is to fork my own copy of letsencrypt-webapp-renewer as well as letsencrypt-azure and make the changes myself? Or is there some other option that I'm overlooking? BTW -- thanks for all of your help with this!

Also, you had mentioned earlier that non-wildcard certs could not be verified by ACME challenge. I'm not sure I understand how the HTTP verification works -- do I have to have special code in my app to handle a specific request?

@ohadschn
Copy link
Owner

ohadschn commented Jun 12, 2020

  1. Yes, you could fork both projects and make the changes - should be pretty straightforward. You already have what you need in that PR, so it's just a matter of consuming it in a forked version of this project. One easy option would be to publish your forked letsencrypt-azure library to some NuGet feed and then reference it in your forked letsencrypt-webapp-renewer.
  2. You never explained why you can't just use *.mydomain.com - pretty sure that will also catch *.etracker.mydomain.com
  3. There is actually a free, automatically renewed Digicert-based solution build in Azure Apps (in preview): https://docs.microsoft.com/en-us/azure/app-service/configure-ssl-certificate#create-a-free-certificate-preview. It doesn't support wildcards but you could just create one for each subdomain. Note that it doesn't support the naked domain either (yoursite.com), so you'd have to use the HTTP challenge for it.
  4. You don't need any special code in your app for the ACME HTTP challenge, but you do need to make sure your settings don't interfere with it. Basically the WebJob generates the challenge response files in a folder whose files would be served by the App Service by default (in a path like http://www.mywebapp.com/.well-known/acme-challenge/586-mTwMenbfkS8WxQYIsVmjE_J2ffiGxzAGEpl85uU). As long as you don't change that default it should work. If it doesn't, you can usually find the answer in the original extension's issues. One common issue is forcing HTTPS for all served files, as the challenge takes place over HTTP (for obvious chicken and the egg reasons).

@roddharris
Copy link
Author

Thanks @ohadschn. In regards to question 2 -- I was pretty sure I tried that at one point and it didn't work -- I can give it another shot though because if it did work, that might save me a lot of headache.

Thanks for the info in items 3 and 4.

Again, thanks for all of your help on this!

@roddharris
Copy link
Author

roddharris commented Jun 15, 2020

Just an FYI, from what I've found, the wildcard cert doesn't appear to cover the root domain

edit
OR parent sub-domains. (i.e. *.mydomain.com won't cover *.etracker.mydomain.com)

https://serverfault.com/questions/310530/should-a-wildcard-ssl-certificate-secure-both-the-root-domain-as-well-as-the-sub

https://www.instantssl.com/multi-level-wildcard

https://stackoverflow.com/questions/2115611/wildcard-ssl-on-sub-subdomain

@ohadschn
Copy link
Owner

Thanks @ohadschn. In regards to question 2 -- I was pretty sure I tried that at one point and it didn't work -- I can give it another shot though because if it did work, that might save me a lot of headache.

Definitely worth a shot IMO

Just an FYI, from what I've found, the wildcard cert doesn't appear to cover the root domain.

True, which is why you'd need bullet (4) regardless (HTTP challenge). I should probably clarify that better in the docs...

@roddharris
Copy link
Author

One last question about the HTTP challenge. Does that challenge happen against the web app hosting the letsencrypt webjob or against the actual web app for which you are adding the cert? I'm guessing its the actual web app but just wanted to be certain.

@ohadschn
Copy link
Owner

You are correct, it's against the actual web app

@roddharris
Copy link
Author

@ohadschn , I've done the following:

  1. Cloned a copy of letsencrypt-azure
  2. Made the changes that were included in the pull request.
  3. Published my modified version to NuGet
  4. Cloned a copy of letsencrypt-webapp-renewer
  5. Removed the existing LetsEncryptAzure NuGet package and added my package
  6. Rebuilt the project
  7. Copied the src folder, .gitattributes, .gitignore, license and readme.md files into a folder then created a zipped file of that folder.
  8. Tried creating a web job on my web app by uploading the zip folder -- FAIL

Each time I try to create the web job, I get a very basic error: Failed to add --webjobname--

This is way out of my league -- I've never done any of this stuff before.

Is there something special I have to do to create this zip file for the web job?

@roddharris
Copy link
Author

roddharris commented Jun 23, 2020

So I found that if I right click the .WebJob project, there is an option to Publish as an Azure WebJob. I did this and Success! Wahoo!

Thanks for all your help!

@ohadschn ohadschn added blocked and removed question labels Jun 23, 2020
@ohadschn
Copy link
Owner

Nice! Glad you sorted it out :)

Let's leave this bug open until the PR (sjkp/letsencrypt-azure#5) is merged to the main repo and I can update this project.

@ohadschn ohadschn changed the title Error: At least one name server must be configured. Support for subdomain wildcards Jul 16, 2020
@roddharris
Copy link
Author

Hello again. I hadn't been paying attention to this for a while and just logged in today to see how things were going with my cert management. I noticed that my web job has failed the last two times it ran -- automated. However, when I log in and run the job it runs fine. I got the following error:

[11/01/2020 00:01:59 > 37caee: INFO]     DateTime=2020-11-01T00:01:59.2430753Z
[11/01/2020 00:01:59 > 37caee: INFO] LetsEncrypt.Azure.Core.V2.AcmeClient Information: 0 : 6373978571924307536 - Response: POST https://acme-v02.api.letsencrypt.org/acme/chall-v3/8276718323/cdE0Xw, headers 
[11/01/2020 00:01:59 > 37caee: INFO] {
[11/01/2020 00:01:59 > 37caee: INFO]   "type": "dns-01",
[11/01/2020 00:01:59 > 37caee: INFO]   "status": "invalid",
[11/01/2020 00:01:59 > 37caee: INFO]   "error": {
[11/01/2020 00:01:59 > 37caee: INFO]     "type": "urn:ietf:params:acme:error:dns",
[11/01/2020 00:01:59 > 37caee: INFO]     "detail": "During secondary validation: DNS problem: networking error looking up TXT for _acme-challenge.myapp.mydomain.com",
[11/01/2020 00:01:59 > 37caee: INFO]     "status": 400
[11/01/2020 00:01:59 > 37caee: INFO]   },
[11/01/2020 00:01:59 > 37caee: INFO]   "url": "https://acme-v02.api.letsencrypt.org/acme/chall-v3/.../cdE0Xw",
[11/01/2020 00:01:59 > 37caee: INFO]   "token": "...",
[11/01/2020 00:01:59 > 37caee: INFO]   "validationRecord": [
[11/01/2020 00:01:59 > 37caee: INFO]     {
[11/01/2020 00:01:59 > 37caee: INFO]       "hostname": "myapp.mydomain.com"
[11/01/2020 00:01:59 > 37caee: INFO]     }
[11/01/2020 00:01:59 > 37caee: INFO]   ]
[11/01/2020 00:01:59 > 37caee: INFO] }

It looks like maybe its a permissions thing, but I'm not sure exactly what to check.

@ohadschn
Copy link
Owner

ohadschn commented Nov 3, 2020

I don't think it's a permissions error, the error is 400 bad request due to a "networking error" (permissions issues would have been 401 Unauthorized / 403 Forbidden).

I suspect retries are the way to go here: #114

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants