Skip to content

Commit 67801e0

Browse files
committed
Add context to CertExpired errors
1 parent 0b11aef commit 67801e0

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/error.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ pub enum Error {
3838

3939
/// The certificate is expired; i.e. the time it is being validated for is
4040
/// later than the certificate's notAfter time.
41-
CertExpired,
41+
CertExpired {
42+
/// The validation time.
43+
time: UnixTime,
44+
/// The notAfter time of the certificate.
45+
not_after: UnixTime,
46+
},
4247

4348
/// The certificate is not valid for the name it is being validated for.
4449
CertNotValidForName(InvalidNameContext),
@@ -228,7 +233,7 @@ impl Error {
228233
pub(crate) fn rank(&self) -> u32 {
229234
match &self {
230235
// Errors related to certificate validity
231-
Self::CertNotValidYet { .. } | Self::CertExpired => 290,
236+
Self::CertNotValidYet { .. } | Self::CertExpired { .. } => 290,
232237
Self::CertNotValidForName(_) => 280,
233238
Self::CertRevoked | Self::UnknownRevocationStatus | Self::CrlExpired => 270,
234239
Self::InvalidCrlSignatureForPublicKey | Self::InvalidSignatureForPublicKey => 260,

src/verify_cert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ fn check_validity(input: &mut untrusted::Reader<'_>, time: UnixTime) -> Result<(
381381
return Err(Error::CertNotValidYet { time, not_before });
382382
}
383383
if time > not_after {
384-
return Err(Error::CertExpired);
384+
return Err(Error::CertExpired { time, not_after });
385385
}
386386

387387
// TODO: mozilla::pkix allows the TrustDomain to check not_before and

0 commit comments

Comments
 (0)