You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug Report: Let's Encrypt Account URL Not Being Retrieved for cmdeploy dns
Issue Description
The cmdeploy dns command fails with the error message "could not get letsencrypt account url, please run 'cmdeploy run'" even after successfully running cmdeploy run. This occurs because the command relies on acmetool account-url to retrieve the Let's Encrypt account URL, but this command sometimes fails to return the URL despite the account being properly set up and the URL file existing on the file system.
Steps to Reproduce
Deploy a new server using cmdeploy run (which successfully completes)
Verify that Let's Encrypt certificates are properly generated (visible in /var/lib/acme/)
Run cmdeploy dns to configure DNS settings
Observe the error: "could not get letsencrypt account url, please run 'cmdeploy run'"
Manually check that the account URL file exists with: cat /var/lib/acme/accounts/acme-v02.api.letsencrypt.org%2fdirectory/*/url
Expected vs. Actual Behavior
Expected behavior:
After a successful cmdeploy run, the cmdeploy dns command should retrieve the Let's Encrypt account URL from the system and use it to generate proper DNS configuration instructions.
Actual behavior:
The cmdeploy dns command fails with "could not get letsencrypt account url, please run 'cmdeploy run'" even though:
The cmdeploy run command completed successfully
The Let's Encrypt account URL file exists at /var/lib/acme/accounts/acme-v02.api.letsencrypt.org%2fdirectory/*/url
The URL can be read manually using cat
The acmetool account-url command fails to return the URL (returns empty string)
Root Cause
The acmetool account-url command sometimes doesn't properly read the URL file despite the file being present and readable. The rdns.py script only used this command to retrieve the URL with no fallback mechanism.
Solution Implemented
Added a fallback method in rdns.py that directly reads the URL file from the filesystem when the acmetool account-url command fails:
defget_acme_account_url():
"""Get the acmetool account URL with fallback methods. First tries the acmetool command, then falls back to searching the filesystem if the command fails or returns empty. """# Try the acmetool command firstacme_url=shell("acmetool account-url", fail_ok=True)
ifacme_url:
returnacme_url# Fallback: search for URL files in acme accounts directorytry:
acct_base="/var/lib/acme/accounts/"# Find Let's Encrypt directoryle_dirs=glob.glob(os.path.join(acct_base, "*letsencrypt*"))
ifnotle_dirs:
return""# Find account directoriesforle_dirinle_dirs:
acct_dirs=glob.glob(os.path.join(le_dir, "*"))
foracct_dirinacct_dirs:
url_file=os.path.join(acct_dir, "url")
ifos.path.isfile(url_file):
# Read the URL file contentwithopen(url_file, "r") asf:
url=f.read().strip()
ifurl:
returnurlexceptException:
# Any exception during fallback should be ignoredpassreturn""
Then updated the perform_initial_checks function to use this new function:
res["acme_account_url"] =get_acme_account_url()
Testing Notes
After implementing the fix:
The cmdeploy dns command now successfully retrieves the Let's Encrypt account URL even when the acmetool account-url command fails
The command correctly generates all required DNS entries, including the CAA record with the proper account URL
The fix is robust against potential errors in filesystem operations by wrapping the fallback in a try-except block
The solution maintains backward compatibility by first trying the original method before falling back to the direct file reading
Additional Information
This bug may affect both new deployments and existing deployments where the acmetool command isn't functioning properly. The fix ensures that DNS configuration can proceed even in cases where there might be issues with the acmetool command-line utility.
Affected Files
cmdeploy/src/cmdeploy/remote/rdns.py
The text was updated successfully, but these errors were encountered:
supere989
added a commit
to supere989/relay
that referenced
this issue
Apr 5, 2025
When acmetool account-url command fails, directly read the URL from filesystem.
This ensures cmdeploy dns can proceed even if the acmetool command
is not functioning properly.
Fixeschatmail#545
When acmetool account-url command fails, directly read the URL from filesystem.
This ensures cmdeploy dns can proceed even if the acmetool command
is not functioning properly.
Fixes#545
Bug Report: Let's Encrypt Account URL Not Being Retrieved for
cmdeploy dns
Issue Description
The
cmdeploy dns
command fails with the error message "could not get letsencrypt account url, please run 'cmdeploy run'" even after successfully runningcmdeploy run
. This occurs because the command relies onacmetool account-url
to retrieve the Let's Encrypt account URL, but this command sometimes fails to return the URL despite the account being properly set up and the URL file existing on the file system.Steps to Reproduce
cmdeploy run
(which successfully completes)/var/lib/acme/
)cmdeploy dns
to configure DNS settingscat /var/lib/acme/accounts/acme-v02.api.letsencrypt.org%2fdirectory/*/url
Expected vs. Actual Behavior
Expected behavior:
cmdeploy run
, thecmdeploy dns
command should retrieve the Let's Encrypt account URL from the system and use it to generate proper DNS configuration instructions.Actual behavior:
cmdeploy dns
command fails with "could not get letsencrypt account url, please run 'cmdeploy run'" even though:cmdeploy run
command completed successfully/var/lib/acme/accounts/acme-v02.api.letsencrypt.org%2fdirectory/*/url
cat
acmetool account-url
command fails to return the URL (returns empty string)Root Cause
The
acmetool account-url
command sometimes doesn't properly read the URL file despite the file being present and readable. Therdns.py
script only used this command to retrieve the URL with no fallback mechanism.Solution Implemented
Added a fallback method in
rdns.py
that directly reads the URL file from the filesystem when theacmetool account-url
command fails:Then updated the
perform_initial_checks
function to use this new function:Testing Notes
After implementing the fix:
cmdeploy dns
command now successfully retrieves the Let's Encrypt account URL even when theacmetool account-url
command failsAdditional Information
This bug may affect both new deployments and existing deployments where the
acmetool
command isn't functioning properly. The fix ensures that DNS configuration can proceed even in cases where there might be issues with theacmetool
command-line utility.Affected Files
cmdeploy/src/cmdeploy/remote/rdns.py
The text was updated successfully, but these errors were encountered: