1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:57:35 +00:00

LibTLS: ASN1 parse_utc_time handle pre 2000 years

In this format the year is specified using two digits. In the case that
these digits are 50 or more, we should assume that the year is in
1950-1999. If it is 49 or less, the year is 2000-2049.

This is specified in RFC5280 section 4.1.2.5.1.
This commit is contained in:
Michiel Visser 2022-02-21 22:15:41 +01:00 committed by Ali Mohammad Pur
parent fea5aeda0b
commit f8ce0eb648

View file

@ -110,7 +110,9 @@ Optional<Core::DateTime> parse_utc_time(StringView time)
return {}; return {};
} }
auto full_year = (Core::DateTime::now().year() / 100) * 100 + year_in_century.value(); // RFC5280 section 4.1.2.5.1.
auto full_year = year_in_century.value();
full_year += (full_year < 50) ? 2000 : 1900;
auto full_seconds = seconds.value_or(0); auto full_seconds = seconds.value_or(0);
// FIXME: Handle offsets! // FIXME: Handle offsets!