Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support certs with GeneralTime #167

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions src/cluster_crypto/cert_key_pair/cert_mutations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,16 @@ fn extend_certificate_expiration(tbs_certificate: &mut TbsCertificate) -> Result
}

fn get_certificate_expiration(tbs_certificate: &mut TbsCertificate) -> Result<(DateTime<Utc>, DateTime<Utc>)> {
let (current_not_before, current_not_after) = match &tbs_certificate.validity.not_before {
x509_certificate::asn1time::Time::UtcTime(not_before) => {
match &tbs_certificate.validity.not_after {
x509_certificate::asn1time::Time::UtcTime(not_after) => {
// Dereferencing is the only way to get a chrono::DateTime out of the
// x509_certificate::asn1time::UtcTime struct.
(*(not_before.clone()), *(not_after.clone()))
}
x509_certificate::asn1time::Time::GeneralTime(_) => bail!("GeneralTime not supported"),
}
}
x509_certificate::asn1time::Time::GeneralTime(_) => bail!("GeneralTime not supported"),
let current_not_before: DateTime<Utc> = match &tbs_certificate.validity.not_before {
x509_certificate::asn1time::Time::UtcTime(not_before) => *(not_before.clone()),
x509_certificate::asn1time::Time::GeneralTime(not_before) => (*not_before).clone().into(),
};

let current_not_after: DateTime<Utc> = match &tbs_certificate.validity.not_after {
x509_certificate::asn1time::Time::UtcTime(not_after) => *(not_after.clone()),
x509_certificate::asn1time::Time::GeneralTime(not_after) => (*not_after).clone().into(),
};

Ok((current_not_before, current_not_after))
}

Expand Down
Loading