Skip to content

Commit

Permalink
Merge pull request #2144 from catch-error/fix/leap-year-check
Browse files Browse the repository at this point in the history
Fix leap year check
  • Loading branch information
DL6ER authored Dec 29, 2024
2 parents 1c1dff7 + deeb755 commit 2fef926
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/webserver/x509.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ bool generate_certificate(const char* certfile, bool rsa, const char *domain)
tm->tm_year += 30; // 30 years from now
// Check for leap year, and adjust the date accordingly
const bool isLeapYear = tm->tm_year % 4 == 0 && (tm->tm_year % 100 != 0 || tm->tm_year % 400 == 0);
tm->tm_mday = tm->tm_mon == 2 && tm->tm_mday == 29 && !isLeapYear ? 28 : tm->tm_mday;
tm->tm_mday = tm->tm_mon == 1 && tm->tm_mday == 29 && !isLeapYear ? 28 : tm->tm_mday;
strftime(not_after, sizeof(not_after), "%Y%m%d%H%M%S", tm);

// 1. Create CA certificate
Expand Down

0 comments on commit 2fef926

Please sign in to comment.