certbot on Debian Bookworm fails with: The peer didn't know the key we used

Posted by ads on Monday, 2025-06-09
Posted in [Lets-Encrypt][Linux][Software]

Was setting up a new Debian Bookworm system in my home environment. So far I was not using certificates at home, and wanted to change this along the way, using Let’s Encrypt. Since the IP-addresses here are RFC1918, I can’t use the http01 challenge, and have to resort to dns01 challenges. On Debian Bookworm, using certbot, this fails reproducible.

1
Encountered error when making query: The peer didn't know the key we used

Note: Domain names in this blog posting are protected, I’m not really using the home zone but a valid domain name.

The Setup

Freshly installed Debian Bookworm system, with all upgrades. No other additionally software installed, only certbot.

On the DNS-Server side I’m using bind9, with DNSSEC for zone updates. I am regularly using zone updates already for other use cases, but I never used it before for Let’s Encrypt. That part is new.

My original intention was to spin up a new Grafana VM, and encrypt the access to the web interface.

In my DNS server I added a new key, and an update policy to the zone I’m using at home:

1
2
3
4
5
6
7
8
zone "home" {
	type master;
	file "/etc/bind/dynamic-updates/home.zone";
	allow-query { any; };
	update-policy {
		grant "letsencrypt-home-grafana" subdomain grafana.home. TXT;
	};
};

Then I installed and configured certbot:

1
cat /etc/letsencrypt/dns-rfc2136.ini
1
2
3
4
5
6
dns_rfc2136_server = 1.2.3.4
dns_rfc2136_port = 53
dns_rfc2136_name = letsencrypt-home-grafana
dns_rfc2136_secret = <secret>
dns_rfc2136_algorithm = hmac-sha256
dns_rfc2136_sign_query = true

And ran the certonly command:

1
certbot certonly --dns-rfc2136 --dns-rfc2136-credentials /etc/letsencrypt/dns-rfc2136.ini -d grafana.home. --agree-tos --no-eff-email -m dns@home --force-renewal

Resulting in the following error:

1
2
3
4
5
6
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Account registered.
Requesting a certificate for grafana.home
Encountered exception during recovery: certbot.errors.PluginError: Encountered error when making query: The peer didn't know the key we used
Encountered error when making query: The peer didn't know the key we used
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.

Strange.

Debugging

My first thought was that I did something wrong setting up the zone, or the dnssec setup. After all, I did not use dns01 before. I went as far as throwing everything out and redo it from scratch. And checked the Playbook twice. No bueno.

Then I tried nsupdate directly:

1
cat /tmp/update.txt
1
2
3
4
5
server 1.2.3.4
key hmac-sha256:letsencrypt-home-grafana. <secret>
update delete _acme-challenge.grafana.home.de. TXT
update add _acme-challenge.grafana.home. 300 TXT "challenge-token"
send
1
nsupdate -v -d /tmp/update.txt

Which worked out of the box. Same dnssec key, same hostname for the ACME update.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Reply from SOA query:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id:  30487
;; flags: qr aa; QUESTION: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; QUESTION SECTION:
;_acme-challenge.grafana.home. IN SOA

;; AUTHORITY SECTION:
home.     60      IN      SOA     ns11. postmaster. 2025060807 7200 900 604800 7200

;; TSIG PSEUDOSECTION:
letsencrypt-home-grafana. 0     ANY     TSIG    hmac-sha256. 1749403629 300 32 <hash>= 30487 NOERROR 0

Found zone name: home
The primary is: 1.2.3.4
Sending update to 1.2.3.4#53
Outgoing update query:
;; ->>HEADER<<- opcode: UPDATE, status: NOERROR, id:   9041
;; flags:; ZONE: 1, PREREQ: 0, UPDATE: 2, ADDITIONAL: 1
;; UPDATE SECTION:
_acme-challenge.grafana.home. 0 ANY TXT
_acme-challenge.grafana.home. 300 IN TXT "challenge-token"

;; TSIG PSEUDOSECTION:
letsencrypt-home-grafana. 0     ANY     TSIG    hmac-sha256. 1749403629 300 32 <hash>= 9041 NOERROR 0


Reply from update query:
;; ->>HEADER<<- opcode: UPDATE, status: NOERROR, id:   9041
;; flags: qr; ZONE: 1, PREREQ: 0, UPDATE: 0, ADDITIONAL: 1
;; ZONE SECTION:
;home.            IN      SOA

;; TSIG PSEUDOSECTION:
letsencrypt-home-grafana. 0     ANY     TSIG    hmac-sha256. 1749403629 300 32 <hash>= 9041 NOERROR 0

WOW!

Even more debugging

I have Ansible playbooks, and I have a Proxmox host! Therefore I spun up two new systems, one Debian Bookworm and one Debian Trixie (the upcoming stable release). Both got their own entry in my home zone, and use the same dnssec key. Both are installed using the same Playbook.

Out of the box, Trixie works. Bookworm fails.

Bookworm is certbot version 2.1.0-4, which was released in December 2022.

Trixie is certbot version 4.0.0-2, which was released in April 2025.

Conclusion

Looks like I fell for wanting a stable system (Debian) and instead got a very outdated piece of software. Based on the stone age of the software in Bookworm, I’m not going to bother to file a bug request. This blog posting here is mainly to document the findings.

The next question is: do I want to stick with Debian, and if yes, which version. And do I want to stick with certbot, or switch to something like lego instead.


Categories: [Lets-Encrypt] [Linux] [Software]

Comments

With an account on the Fediverse or Mastodon, you can respond to this post. Known replies are displayed below:



Note: This will load data from mastodon.social.

Learn how this is implemented here.


Share: