Skip to content

Commit bee8a6e

Browse files
Add notes about UTCTime range being 1970-2049 (#1052)
RFC 5280 says that `UTCTime` is 1950-2049, however due the common use of computer times being based off of `UNIX_EPOCH` the implementation of [`UtcTime`](https://docs.rs/der/latest/der/asn1/struct.UtcTime.html) is limited to 1970. This limitation is due to the `MIN_YEAR` bounding valid [`DateTime`](https://docs.rs/der/latest/der/struct.DateTime.html) structs. The `DateTime` struct is the underlying implementation of `UTCTime`.
1 parent 3b3def5 commit bee8a6e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

der/src/asn1/utc_time.rs

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ use std::time::SystemTime;
2525
/// > interpreted as `19YY`; and
2626
/// > - Where `YY` is less than 50, the year SHALL be interpreted as `20YY`.
2727
///
28+
/// Note: Due to common operations working on `UNIX_EPOCH` [`UtcTime`]s are
29+
/// only supported for the years 1970-2049.
30+
///
2831
/// [1]: https://tools.ietf.org/html/rfc5280#section-4.1.2.5.1
2932
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
3033
pub struct UtcTime(DateTime);

x509-cert/src/time.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ use std::time::SystemTime;
2424
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
2525
#[derive(Choice, Copy, Clone, Debug, Eq, PartialEq, ValueOrd)]
2626
pub enum Time {
27-
/// Legacy UTC time (has 2-digit year, valid only through 2050).
27+
/// Legacy UTC time (has 2-digit year, valid from 1970 to 2049).
28+
///
29+
/// Note: RFC 5280 specifies 1950-2049, however due to common operations working on
30+
/// `UNIX_EPOCH` this implementation's lower bound is 1970.
2831
#[asn1(type = "UTCTime")]
2932
UtcTime(UtcTime),
3033

0 commit comments

Comments
 (0)