Skip to content

fix(ssl): validate le-mail before letsencrypt registration - #496

Open
mrrobot47 wants to merge 2 commits into
EasyEngine:developfrom
mrrobot47:fix/validate-le-mail
Open

mrrobot47 wants to merge 2 commits into
EasyEngine:developfrom
mrrobot47:fix/validate-le-mail

Conversation

@mrrobot47

@mrrobot47 mrrobot47 commented Jun 30, 2026 •

Copy link
Copy Markdown
Member

Problem

The Let's Encrypt account email (le-mail) was resolved with a ?? fallback that only guards null/unset — an empty string passed straight through to ACME register()/request(), producing a generic, confusing ACME failure. This affected init_le, ssl_verify, and ssl_renew.

Fix

Add a shared get_validated_le_mail() helper: resolve from config (or prompt interactively), validate non-empty + filter_var( …, FILTER_VALIDATE_EMAIL ), and hard-error with a clear message (Set it with \ee config set le-mail `.`) when it can't be resolved (e.g. non-interactive cron with no le-mail set). All three sites route through it.

If no valid email can be resolved during ee site create --ssl=le or ee site update --ssl=le, the helper throws, so site creation goes through the normal clean-up (no orphaned containers, webroot or proxy config). ssl-verify and ssl-renew print the same "A valid Let's Encrypt email is required…" error and exit 1. When ssl-renew has already resolved the email, init_le() doesn't prompt a second time.

In the renewal path the email is resolved after the 'le'/'inherit' site-type guard in renew_ssl_cert(), so a non-LE single-site ssl-renew still gets the accurate "Only Letsencrypt certificate renewal is supported." error rather than an email error.

Note

Behaviour change: hosts with an empty or invalid le-mail now stop at renewal with the le-mail error, including the nightly ssl-renew --all cron (which stops at the first LE site). Such renewals may previously have gone through against an already-registered account. Set a valid le-mail (ee config set le-mail <email>) before upgrading.

Testing

Manual: with le-mail unset/garbage, a non-interactive LE issuance/renew now exits cleanly with the "valid email required" message instead of an opaque ACME error; a valid le-mail proceeds as before; a non-LE ssl-renew still reports the site-type error.

Tested on Ubuntu 26.04 with EasyEngine 4.12.0: create --ssl=le with no le-mail and with a garbage le-mail plus an invalid answer at the prompt (clean rollback, config unchanged), ssl-renew/ssl-verify on an LE site with no le-mail, ssl-renew on a non-LE site (site-type error, no prompt), and a create with a valid le-mail (no prompt).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

get_validated_le_mail() called EE::error(), which exits the process. During `ee site create --ssl=le` this bypassed the create try/catch, so an empty or invalid email at the prompt left an orphaned site (containers, webroot and proxy config, but no DB entry; re-create fails with "Webroot directory ... already exists"). Before the helper, the bad email made register() throw and the site was rolled back.

Throw an exception instead so create and `ee site update --ssl` handle it through their existing catch blocks, and convert it to EE::error() in the direct ssl-verify and ssl-renew entry points. init_le() also reuses an already resolved le_mail, so a renewal no longer prompts twice.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants