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.
Fix --days flag to properly calculate renewal time with --valid-to
Summary
When using
--valid-towith--days, the renewal time was incorrectly set to 1 day before certificate expiry instead of respecting the user's--daysvalue. This fix ensures renewal is scheduled at the specified number of days after issuance, as intended.Background & Business Need
Our institution is proactively preparing for the industry-wide transition to shorter certificate lifetimes ahead of the 2029 deadline. We've moved to 47-day certificates now to:
Original Problem
The
--daysflag in acme.sh was being ignored for short-lived certificates:--days 60worked as expected--daysvalue was ignored, renewal defaulted to 1 day before expirationRoot Cause: The renewal calculation logic had separate code paths where short-lived certificates (when
_notAfteris set) ignoredLe_RenewalDaysand used hardcoded fallback logic instead of respecting user preferences.Update: Simplified Approach
After real-world testing, I simplified the fix:
Removed:
Reasoning:
The Solution
Modified the renewal calculation logic to match the behavior when
--valid-tois NOT used:Le_UserRenewTimeasLe_CertCreateTime + Le_RenewalDays * 86400Le_CertExpireTimeto validate renewal time is before expiry