acme: use the hotplug system #17721
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 582 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.381
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #17721"
general
weight: 0.35
hgl
Signed-off-by: Glen Huang <heyhgl@gmail.com>
Maintainer: @tohojo
Compile tested: not yet
Run tested: not yet
cc httpd maintainers and major contributors: @micmac1 @Ansuel @neheb @peter-stadler @jow- @feckert @nbd168
Why
This PR might come off as presumptuous, since it removes a lot of code and is not backward compatible, but allow me to explain myself.
I think the acme package suffers from assuming too much responsibilities for interacting with httpds. It currently does the following:
1. Finding and turning off httpds listening on port 80 when standalone mode is specified.
2. Making httpds reload once certs are issued/renewed.
The way it does them is pretty brittle (also dangerous, since it modifies other package's config files), and it has to account for every supported httpd, which is unmaintainable.
The situation can be improved, if:
1. This package uses the hotplug system to send issue/renew events
2. Each httpd package plugs into the system, and coordinates with this package via such events.
How
This package has to interact with httpds in the following ways:
1. HTTP-01 via webfoot
2. HTTP-01 via acme.sh standalone mode
3. Make the httpd reload the new certificates
For
#1, currently the user is allowed to specify a path. With the hotplug system however, it should be a well-defined path like/var/run/acme/challenge, so each httpd can just serve challenge from this dir to make acme work.For
#2, it should be the user's responsibility to not use the standalone mode when a httpd is listening on 80. The way this package currently finds httpds is flawed, since it checks if port 80 is used on any interfaces, but standalone mode only requires 80 on WAN. Turning them off and restarting them later is also brittle.For
#3, if the hotplug system is employed, this package will call hotplud.d/acme, and scripts in it will be called with environment variables denoting if a domain is (about to be issued/issued/renewed/failed to do the proceedings) along with others that are set by acme.sh. Each httpd should know better how it should reload itself and add certificates to its config when first issuing.This package also supports user script options for setting up and cleaning up. They can be removed as the user can just put scripts in the hotplug system.
Implementation
This PR has not been tested. It only serves to start the conversation, and demonstrates how it should work in theory. Once the design is finalized, I will make sure it's actually runnable and hopefully bug-free. At the moment, I'd be interested to know if @tohojo and httpd maintainers and major contributors think this approach is sound, and if adding acme support in each httpd package is something the maintainers and contributors would oppose to.
To reload a httpd after successfully issuing or renewing a certificate, a hotplug script could look something like:
This script ideally should ideally live in a separate package like nginx-acme, so it can be optionally enabled.
An even simpler approach is to require that the user runs this package at least once (either via the command line or LuCI), before specifying the certificates in the httpd config. That way the hotplug script no longer needs to mess with user's config.
I also wonder, since it's not backward compatible, should it be implemented as a separate package? Or it should be updated in place only for a new OpenWrt major version?
Details
I also took the liberty to change some small things, let me know if you think any of them are terrible ideas:
1. It should not use a init script since it's not a daemon.
2. Cron job is added once by ipk, instead of checking repeatedly by command.
3. Cron job is run each month, instead of every day.
2.
certsection is enabled by default, to follow the convention.3. Renamed option
use_stagingtostaging.4. Use
ec-256askeylengthby default.5. No need to resend INT signal, since it's not prevented.
6. Rename
errtologerr8. Cleaning up is automatically run at shell exit, not at the end of each issue_cert.
9. Keep issuing certificates if one fails.
10. Not printing logs where they should be clear either from acme.sh's logs or passed flags
Questions
I'm not sure what
CURL_CA_BUNDLEandNO_TIMESTAMPare for?