plugins: os-acme-client | Cloudflare - domain validation failed (dns01)
Important notices Before you add a new report, we ask you kindly to acknowledge the following:
- I have read the contributing guide lines at https://github.com/opnsense/plugins/blob/master/CONTRIBUTING.md
- I have searched the existing issues, open and closed, and I’m convinced that mine is new.
- The title contains the plugin to which this issue belongs
Describe the bug After upgrading to OPNsense 24.1.5_3, the ACME client is no longer able to create TXT records using the Cloudflare DNS-01 challenge type.
To Reproduce Steps to reproduce the behavior:
- Go to Services
- Click on ACME Client > Certificates
- Switch to Certificates
- Last ACME Status > validation vailed
Expected behavior validation ok
Relevant log files ACME Log: interestingly, the acme log is empty and all outputs were recorded to the system log.
System Log:
2024-04-07T15:28:46-04:00 opnsense 81230 - [meta sequenceId="6"] AcmeClient: certificate must be issued/renewed: <redacted_domain>
2024-04-07T15:28:46-04:00 opnsense 81230 - [meta sequenceId="7"] AcmeClient: issue certificate: <redacted_domain>
2024-04-07T15:28:46-04:00 opnsense 81230 - [meta sequenceId="8"] AcmeClient: using CA: letsencrypt
2024-04-07T15:28:46-04:00 opnsense 81230 - [meta sequenceId="9"] AcmeClient: account is registered: <redacted_letsencrypt_account>
2024-04-07T15:28:46-04:00 opnsense 81230 - [meta sequenceId="10"] AcmeClient: using challenge type: <redacted_dns_challenge_name>
2024-04-07T15:28:46-04:00 opnsense 81230 - [meta sequenceId="11"] AcmeClient: running acme.sh command: /usr/local/sbin/acme.sh --issue --syslog 7 --debug --server 'letsencrypt' --dns 'dns_cf' --home '/var/etc/acme-client/home' --cert-home '/var/etc/acme-client/cert-home/<redacted_cert_path>' --certpath '/var/etc/acme-client/certs/<redacted_cert_path>/cert.pem' --keypath '/var/etc/acme-client/keys/<redacted_cert_path>/private.key' --capath '/var/etc/acme-client/certs/<redacted_cert_path>/chain.pem' --fullchainpath '/var/etc/acme-client/certs/<redacted_cert_path>/fullchain.pem' --domain '<redacted_domain>' --domain '<redacted_domain>' --days '1' --keylength '4096' --accountconf '/var/etc/acme-client/accounts/<redacted_account>_prod/account.conf'
2024-04-07T15:28:52-04:00 acme.sh 35127 - [meta sequenceId="12"] [Sun Apr 7 15:28:52 EDT 2024] Add txt record error.
2024-04-07T15:28:52-04:00 acme.sh 37611 - [meta sequenceId="13"] [Sun Apr 7 15:28:52 EDT 2024] Error add txt for domain:_acme-challenge.<redacted_domain>
2024-04-07T15:28:52-04:00 acme.sh 41770 - [meta sequenceId="14"] [Sun Apr 7 15:28:52 EDT 2024] Please add '--debug' or '--log' to check more details.
2024-04-07T15:28:52-04:00 acme.sh 44795 - [meta sequenceId="15"] [Sun Apr 7 15:28:52 EDT 2024] See: https://github.com/acmesh-official/acme.sh/wiki/How-to-debug-acme.sh
2024-04-07T15:28:54-04:00 opnsense 81230 - [meta sequenceId="16"] /usr/local/opnsense/scripts/OPNsense/AcmeClient/lecert.php: AcmeClient: The shell command returned exit code '1': '/usr/local/sbin/acme.sh --issue --syslog 7 --debug --server 'letsencrypt' --dns 'dns_cf' --home '/var/etc/acme-client/home' --cert-home '/var/etc/acme-client/cert-home/<redacted_cert_path>' --certpath '/var/etc/acme-client/certs/<redacted_cert_path>/cert.pem' --keypath '/var/etc/acme-client/keys/<redacted_cert_path>/private.key' --capath '/var/etc/acme-client/certs/<redacted_cert_path>/chain.pem' --fullchainpath '/var/etc/acme-client/certs/<redacted_cert_path>/fullchain.pem' --domain '<redacted_domain>' --domain '<redacted_domain>' --days '1' --keylength '4096' --accountconf '/var/etc/acme-client/accounts/<redacted_account>_prod/account.conf''
2024-04-07T15:28:54-04:00 opnsense 81230 - [meta sequenceId="17"] AcmeClient: domain validation failed (dns01)
2024-04-07T15:28:54-04:00 opnsense 81230 - [meta sequenceId="18"] AcmeClient: validation for certificate failed: <redacted_domain>
Additional context #3871 details the same problem, having to manually create the TXT record is not a solution as it defeats the point of ACME. The issue is the ACME client is failing to create the TXT record for validation, it seems.
If I run the command directly, I get additional output stating the dns_cf hook cannot be found:
[Sun Apr 7 15:40:51 EDT 2024] Can not find dns api hook for dns_cf
Environment OPNsense 24.1.5_3-amd64 FreeBSD 13.2-RELEASE-p11
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 6
- Comments: 17 (4 by maintainers)
Hey folks
I had (almost) the same Issue - stopped working at some point in time after upgrade from OPNsense 23.x.x to 24.x.x with the same error messages as OP. Using ACME Client with Cloudflare, I’ve tried several things like changing to Global API key instead of specific CF tokens or adding CAA entries for subdomains (my hostname is router.subdomain.domain.tld) all without success.
To specify the “almost” in the first sentence: I was confused in every failed run about this log entries:
So why is it adding the TXT record two times and why does it fail the second time? After enabling debug log I stumbled across this log entry:
[Fri Jun 28 14:59:51 CEST 2024] Multi domain='DNS:router.<redacted_domain>,DNS:router.<redacted_domain>'After carefully reading the Description in “Edit certificate” I saw this explanation:
Common Name (CN) and first Alt Name (subjectAltName) for this certificate.So basically what is added in the “Common Name” field will automatically also be the first “Alt Name”. In my config I’ve had the Common Name manually copy-pasted from the first field. This was working since I remember installing OPNsense several years ago, but stopped after updating to 24.x.x
So I removed the Alt Name, did “Reset ACME Client” and then force renewed the certificate et voilà - it was working as expected:
So if you have the same issue, shortly check your Common & Alt Name in the GUI and if it has the same values, remove the one in “Alt Names” as it is added automatically anyway as first SAN.
For completeness, I’ve never had this issue here, so nothing to add:
Can not find dns api hook for: dns_cfAnd here are some informations about my setup:
Hope this helps, good luck and best regards
Same issue for all my OPNsense installs which are kept updated in lock-step Previous acme call was done on OPNsense 23.7.9 without issues, given the roughly 2 month time between renews, it’s not possible for me to say which version this started occurring at.
Currently running:
OPNsense 24.1.5_3-amd64
os-acme-client (installed) | 4.1
acme.sh --version https://github.com/acmesh-official/acme.sh v3.0.7
Agreed
Given the acme.sh
_findhook()looks for the script at$LE_WORKING_DIRand it’s not found unless symlinking the/root/.acme.sh/dnsapi/dir to the$LE_WORKING_DIRLooking further into acme.sh setting
$LE_WORKING_DIRit’s done in the main func_process()if specified with the--homeflagWhich OPNsense calls
acme.shwith the following--home '/var/etc/acme-client/home'And if not specified with the
--homeflag the func__initHome()sets the value of$LE_WORKING_DIRto$DEFAULT_INSTALL_HOME$DEFAULT_INSTALL_HOMEis set in the first few lines ofacme.shSeems as though the initial install places the dns scripts at the
$DEFAULT_INSTALL_HOMElocation, then subsequent calls specify the--homeflag with a differing location?same issue with OVH
@MosheL godaddy has other issues: https://github.com/opnsense/plugins/issues/4041
Awesome! Thanks for finding this “hacky fix,” it seems to have resolved the “Can not find dns api hook for dns_cf” error I was seeing. Now to wait an hour to clear the failed validation attempts limit lol!
os-acme-client (installed) | 4.3 | 777KiB | 3 | OPNsense | ACME Client
acme.sh --version https://github.com/acmesh-official/acme.sh v3.0.7
HACKY FIX. So based on my previous post, I did the following work around and symbolically linked to the dnsapi folder from LE working directory:
I then ran a cert update and this fixed the problem. Cert successfully issued!
BUG: Through this whole process, I noticed that setting ACME log to debug doesn’t work properly. There is important info that doesn’t make it into syslog, specifically the exact error message from cloudflare if verification fails. This seems to down to opnsense not passing the right
--syslognumber when I set logging to “debug 3”. The log shows that opnsense passed--syslog 7but 7 is only debug level 1. it should be--syslog 9for debug 3,--syslog 8for debug 2, and--syslog 7for debug 1. I will post this as a separate issue.