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

Retain TXT record after DNS-01 challenge #21

Closed
hk-ng opened this issue Dec 25, 2021 · 4 comments
Closed

Retain TXT record after DNS-01 challenge #21

hk-ng opened this issue Dec 25, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@hk-ng
Copy link

hk-ng commented Dec 25, 2021

In this plugin, it will override the TXT record before the challenge and clear TXT after the challenge.

According to rfc1464, TXT record support multiple attribute and value. Currently it can be used as DNS SPF record, DNS DMARC record and IPFS DNS link reord.

I would suggest to the following workflow instead:

  • Resolve DNS record before dns challenge
  • Append the attribute used for dns challenge and send HTTP request to duckdns server
  • After dns challenge, send HTTP request with original TXT record to duckdns server
@infinityofspace infinityofspace added the enhancement New feature or request label Dec 28, 2021
@infinityofspace
Copy link
Owner

Thanks for your feature suggestion.

The idea makes sense, but unfortunately your described workflow does not work in all cases, because duckdns does not support multiple TXT records and a single TXT record has a maximum length of 255 characters. The DNS challenge has 43 characters and if the previous TXT record is already too long then the DNS challenge fails.

However, I think the following modification of the workflow you described makes sense:

  1. receive the current TXT record
  2. check if the entry is to long so we use a empty TXT entry or in case of a valid length we can add the challenge hash to the existing TXT values
  3. do the DNS challenge
  4. restore previous saved TXT record

The only disadvantage of this procedure with an already too long TXT record would be that possible TXT values cannot be retrieved in the time of the DNS challenge. But I think this is an acceptable disadvantage compared to a completely deleted TXT record.

I will implement the new workflow for the next release v0.7.

@infinityofspace
Copy link
Owner

Current status update on this feature:

After some testing and implementing I can say that sadly the TXT record must contain only the DNS challenge and it cannot be appended to an existing TXT record at least with Lets Encrypt.
However, the new workflow now restores by default the old TXT record that existed before the DNS challenge. Thus, the old TXT value is not available during the DNS Challange, but as soon as the DNS Challange is finished, it is available again.
This behaviour can be disabled with the new argument --dns-duckdns-no-txt-restore.

@SnakeZi
Copy link

SnakeZi commented Nov 19, 2022

My certificate wasn't auto-renewing itself. When in the end it expired I tried to fix it manually... after almost a day of struggling I've found this topic. Adding --dns-duckdns-no-txt-restore to the command fixed everything. Thank you!

Before a fix it was failing with message: "The DNS response does not contain an answer to the question: example.com. IN TXT"

I am using snap version.
certbot v1.32.0 rev 2539
certbot-dns-duckdns v1.1 rev 76

@devedse
Copy link

devedse commented Aug 24, 2023

For me this fix also worked. However I don't get why. Could someone maybe chip in and explain why this is required?
See: NginxProxyManager/nginx-proxy-manager#3138

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

No branches or pull requests

4 participants