大网数据广告活动
服务器运维问答

Which exactly DNS record does Let's Encrypt use to perform DNS-01 challenge validation?

· 52CE 我爱测

I have some SMTP servers (and others) which live behind the NAT and it is infeasible to configure DNAT for HTTP or reverse proxies for them. This means, HTTP-01 and TLS-ALPN-01 are unavailable, so DNS-01 challenge is a natural ch…

问题原文

原帖链接 · Nikita Kipriyanov · CC BY-SA 4.0

I have some SMTP servers (and others) which live behind the NAT and it is infeasible to configure DNAT for HTTP or reverse proxies for them. This means, HTTP-01 and TLS-ALPN-01 are unavailable, so DNS-01 challenge is a natural choice for this case.

For other system I expected to have a wildcard certificate, again it is possible to validate only using DNS-01 challenge.

So I configured everything using certbot-dns-rfc2136 plugin, according to the documentation. I generated a key, configured an update policy in BIND to allow it to update the record _acme-challenge.example.net. (Actually I have the generic policy which allows a key <name>.example.net to update the any record with the same name, so this key may update not only TXT record.)

The following script works as intended (creates the record):

nsupdate -k dns-01.key -v << END
server 192.0.2.1
zone example.net
update add _acme-challenge.example.net 60 TXT "abrakadabra"
send
END

(the key _acme-challenge.example.net is stored in the file dns-01.key).

Then I removed this abrakadabra record and put this key into plugin credentials file.

dns_rfc2136_server = 192.0.2.1
dns_rfc2136_port = 53
dns_rfc2136_name = _acme-challenge.example.net
dns_rfc2136_secret = <some base64 string>
dns_rfc2136_algorithm = HMAC-SHA256

The DNS-01 challenge for the wildcard *.example.net worked successfully:

# certbot certonly --dns-rfc2136 --dns-rfc2136-credentials /path/to/credentials/file.ini -d *.example.net --test-cert
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator dns-rfc2136, Installer None
Requesting a certificate for *.example.net

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/example.net/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/example.net/privkey.pem
   Your certificate will expire on 2022-09-05. To obtain a new or
   tweaked version of this certificate in the future, simply run
   certbot again. To non-interactively renew *all* of your
   certificates, run "certbot renew"

If I request a certificate for a single root domain (... -d example.net), it also works.

The problem is, the same credentials don't work for subdomain names (... -d www.example.net):

# certbot certonly --dns-rfc2136 --dns-rfc2136-credentials /path/to/credentials/file.ini -d www.example.net --test-cert
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator dns-rfc2136, Installer None
Requesting a certificate for www.example.net
Performing the following challenges:
dns-01 challenge for www.example.net
Cleaning up challenges
Encountered exception during recovery: certbot.errors.PluginError: Received response from server: REFUSED
Received response from server: REFUSED

Examining the debug log:

...
2022-06-07 11:35:38,275:DEBUG:certbot_dns_rfc2136._internal.dns_rfc2136:No authoritative SOA record found for _acme-challenge.www.example.net
2022-06-07 11:35:38,276:DEBUG:certbot_dns_rfc2136._internal.dns_rfc2136:No authoritative SOA record found for www.example.net
2022-06-07 11:35:38,277:DEBUG:certbot_dns_rfc2136._internal.dns_rfc2136:Received authoritative SOA response for example.net
2022-06-07 11:35:38,279:ERROR:certbot._internal.error_handler:Encountered exception during recovery: certbot.errors.PluginError: Received response from server: REFUSED
2022-06-07 11:35:38,280:DEBUG:certbot._internal.log:Exiting abnormally:
Traceback (most recent call last):
...

I also tested the same thing with another DNS key, which is permitted to create any records within the zone. The same command worked with this key, which could only mean the certbot-dns-rfc2136 plugin does not try to create _acme-challenge.example.net, and it uses another record instead, _acme-challenge.www.example.net. I confirmed this with the DNS request while waiting for DNS propagation, and also by looking into DNS server log. In this case the refusal was expected, because the former restricted key is only allowed to change _acme-challenge.example.net and not _acme-challenge.www.example.net.

But why it used a record name which I did not expected? Where is that covered in the documentation? I understand it like that _acme-challenge.example.net should be used for validating example.net, *.example.net and <name>.example.net for any <name>, this is given in the second usage example on the documentation page. Am I missing something?

已采纳解答

原帖链接 · Patrick Mevzek · CC BY-SA 4.0

Which exactly DNS record does Let's Encrypt use to perform DNS-01 challenge validation?

dns-01 validation is detailed in the RFC on ACME, aka RFC 8555 "Automatic Certificate Management Environment (ACME)"

It states:

8.4. DNS Challenge

When the identifier being validated is a domain name, the client can prove control of that domain by provisioning a TXT resource record containing a designated value for a specific validation domain name.

and

The record provisioned to the DNS contains the base64url encoding of this digest. The client constructs the validation domain name by prepending the label "_acme-challenge" to the domain name being validated, then provisions a TXT record with the digest value under
that name. For example, if the domain name being validated is
"www.example.org", then the client would provision the following DNS
record:

_acme-challenge.www.example.org. 300 IN TXT "gfj9Xq...Rg85nM"

The CABForum guidelines, as followed by all public CAs, also states:

3.2.2.4.7 DNS Change

Confirming the Applicant's control over the FQDN by confirming the presence of a Random Value or Request Token for either in a DNS CNAME, TXT or CAA record for either 1) an Authorization Domain Name; or 2) an Authorization Domain Name that is prefixed with a Domain Label that begins with an underscore character.

with the following added important information:

Note: Once the FQDN has been validated using this method, the CA MAY also issue Certificates for other FQDNs that end with all the Domain Labels of the validated FQDN. This method is suitable for validating Wildcard Domain Names.

Let's Encrypt own documentation is at https://letsencrypt.org/docs/challenge-types/

DNS-01 challenge

This challenge asks you to prove that you control the DNS for your domain name by putting a specific value in a TXT record under that domain name.

Back to your question, you state:

But why it used a record name which I did not expected?

If you try to validate the name www.example.net, per all the above, the TXT record has to be on _acme-challenge.www.example.net.

I understand it like that _acme-challenge.example.net should be used for validating example.net, *.example.net and .example.net for any , this is given in the second usage example on the documentation page.

First, which documentation page you state? Second, no, in general, each name has to have its validation token. The wildcard *.example.net will also need a specific separate TXT record, on name example.net but with different value than the TXT record on example.net for the name example.net (as in certificates, name *.example.com will NOT cover example.net so the certificate needs to have both listed, and hence both need to be validated, to be valid for both).

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-06-07)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。