Fix: Honor --days flag for short-lived certificates #6572
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes issue where --days flag was ignored for certificates with short validity periods, causing unexpected renewal behavior.
Problem
The
--daysflag in acme.sh is currently ignored for short-lived certificates (typically 5-50 days validity), causing inconsistent behavior:--days 60works as expected--daysvalue is completely ignored, renewal defaults to 1 day before expirationRoot Cause
The renewal calculation logic has separate code paths where short-lived certificates (when
_notAfteris set) ignoreLe_RenewalDaysand use hardcoded fallback logic instead of respecting user preferences.Solution
Enhanced renewal logic (lines ~5388-5427):
_notAftercode path to check user's--dayssetting firstParameter validation (lines ~5351-5364):
--daysparameter (1-398 days range)Testing
✅ Test Case 1:
--days 7with 20-day cert → Renews exactly 7 days after issuance✅ Test Case 2:
--days 25with 20-day cert → Warning + fallback to safe default✅ Test Case 3: Normal certificates maintain existing behavior
Backward Compatibility
--dayscontinue using current logicFuture-Proofing
Prepares for industry transitions to shorter certificate lifespans (398→200→100→47 days by 2029) while respecting user intent.