mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #4875] [Bug]: SSL setup leaves broken acme.sh state on cert issuance failure, --install-cert hook not configured when using option 5 after manual #3405
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#3405
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Mitrl on GitHub (Jun 3, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4875
Describe the bug
When the Let's Encrypt certificate issuance fails during the initial install (e.g. due to an ACME account sync race condition), the installer leaves behind a partial acme.sh domain configuration. Subsequent attempts via menu option 19 → 1 incorrectly detect this broken state as an "existing certificate" and attempt to reuse it, resulting in an empty fullchain.pem (0 bytes). Additionally, menu option 19 → 5 only updates x-ui's internal cert path config but does not set up the acme.sh --install-cert hook, so auto-renewal silently stops copying the renewed cert to the configured paths.
How to reproduce the problem
Steps to reproduce
1.Run the install script. During SSL setup, choose option 1 (Let's Encrypt for Domain). The issuance fails (e.g. ACME accountDoesNotExist error on a fresh acme.sh install).
2.Installation completes without SSL. Enter the panel and go to menu 19 → 1 to retry.
3.The script detects the partial acme.sh config as "Existing certificate found" and skips re-issuance, producing an empty fullchain.pem.
4.Manually delete the broken state and run acme.sh --issue to obtain a valid cert.
5.Go to menu 19 → 5 to set cert paths for the panel. This updates x-ui's config but does not register the --install-cert hook in acme.sh.
6.Verify with acme.sh --info -d : Le_RealCertPath and Le_RealCACertPath are empty; Le_RealFullChainPath may also be unset depending on the path taken.
Expected behavior
On cert issuance failure, the installer should clean up the partial acme.sh domain config and cert directory, not leave broken state behind.
Menu option 19 → 1 should verify that a detected "existing certificate" actually contains valid, non-empty files before reusing it.
Menu option 19 → 5 should also run acme.sh --install-cert with the configured paths and --reloadcmd "x-ui restart" to ensure auto-renewal copies the cert to the correct location.
Actual behavior
Partial acme.sh state persists after failed issuance.
fullchain.pem is created as an empty file (0 bytes).
After manual cert issuance + using option 5, the --install-cert hook is not registered; auto-renewal will not copy the renewed cert to x-ui's configured paths.
Relevant logs
Screenshots
No response
3x-ui version
v3.2.6
Xray-core version
26.6.1
How did you install 3x-ui?
install.sh script
Operating system
Debian 13.5
Which parts of the panel are affected?
Install / upgrade script
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
None
Before submitting
@github-actions[bot] commented on GitHub (Jun 3, 2026):
Thanks for the detailed report and the clear reproduction steps. I've reviewed the relevant code and can confirm all three issues you described.
Issue 1: Partial acme.sh state after failed issuance
In
install.sh(line ~300) andx-ui.sh(ssl_cert_issue, line 1614), the cleanup on failure does:However, acme.sh defaults to ECC (ECDSA) keys and stores those in
~/.acme.sh/${domain}_ecc/, not~/.acme.sh/${domain}/. So the ECC directory is not removed on failure. After the install-time failure,~/.acme.sh/${domain}_ecc/persists with partial state.Issue 2: "Existing certificate" check has no file validity guard
In
ssl_cert_issue()(x-ui.sh, line 1581), the check that setscert_exists=1is:This detects an acme.sh domain entry (from the leftover
_ecc/directory) and immediately setscert_exists=1, skipping re-issuance entirely (line 1608). It then goes straight to--installcert, which attempts to copy~/.acme.sh/${domain}_ecc/fullchain.cer— a file that never existed because issuance failed. The result is the 0-bytefullchain.pemyou observed.A missing guard here would be: check that both
~/.acme.sh/${domain}_ecc/fullchain.cer(or~/.acme.sh/${domain}/fullchain.cer) and the key file are non-empty before trustingcert_exists=1.Issue 3: Option 5 ("Set Cert paths for the panel") skips the
--installcerthookIn
ssl_cert_issue_main()(x-ui.sh, lines 1254–1279), option 5 only calls:This writes the paths into x-ui's settings but never calls
acme.sh --installcert. As a result, acme.sh's domain config (~/.acme.sh/${domain}_ecc/${domain}.conf) never getsLe_RealKeyPath,Le_RealFullChainPath, orLe_ReloadCmdset. Auto-renewal will trigger a new certificate but will not copy it to/root/cert/${domain}/and will not restart x-ui.This matches exactly what you observed with
acme.sh --info -d <domain>showing emptyLe_RealCertPath/Le_RealCACertPath/Le_RealFullChainPath.Workarounds until a fix lands
For bug 1 & 2 — clean the broken state, then re-issue normally via menu option 19 → 1:
Then run
x-ui→ option 19 → option 1 to re-issue.For bug 3 — after option 5 has set the x-ui cert paths, manually register the acme.sh
--installcerthook so renewals copy the cert and restart the panel:Then verify with:
You should see
Le_RealKeyPath,Le_RealFullChainPath, andLe_ReloadCmdall populated.