Skip to content

Conversation

@brahimelhafianatrapalo
Copy link

The local-certs check type was incorrectly calculating the number of days until certificate expiration. The bug was in the warning threshold comparison where it calculated the difference between the warning threshold date and the expiry date, instead of calculating the actual remaining days from now until expiration.

Before this fix:

  • diff = (warning - expiry) / 86400 where warning = now + expiry_warn_days
  • This resulted in reporting (expiry_warn_days - actual_remaining_days) instead of the actual remaining days

Example of incorrect behavior:

  • Current date: December 1, 2025
  • Certificate expires: December 29, 2025
  • Warning threshold: 30 days
  • Reported: "will expire in 2 days" (incorrect)
  • Should report: "will expire in 28 days" (correct)

After this fix:

  • diff = (expiry - rightnow) / 86400
  • This correctly reports the actual number of days remaining until expiration

The fix aligns the warning calculation logic with the expired certificate calculation logic, which was already using (rightnow - expiry) correctly.

The local-certs check type was incorrectly calculating the number of days
until certificate expiration. The bug was in the warning threshold comparison
where it calculated the difference between the warning threshold date and the
expiry date, instead of calculating the actual remaining days from now until
expiration.

Before this fix:
- diff = (warning - expiry) / 86400
  where warning = now + expiry_warn_days
- This resulted in reporting (expiry_warn_days - actual_remaining_days)
  instead of the actual remaining days

Example of incorrect behavior:
- Current date: December 1, 2025
- Certificate expires: December 29, 2025
- Warning threshold: 30 days
- Reported: "will expire in 2 days" (incorrect)
- Should report: "will expire in 28 days" (correct)

After this fix:
- diff = (expiry - rightnow) / 86400
- This correctly reports the actual number of days remaining until expiration

The fix aligns the warning calculation logic with the expired certificate
calculation logic, which was already using (rightnow - expiry) correctly.
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.

1 participant