diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-02-12 21:15:03 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-02-12 23:13:49 +0100 |
| commit | d6b800e1c9a3cdb4f85a2308190afe9f0a856ed4 (patch) | |
| tree | 439b3c142ac392b9888585d51c463696cef6ff87 /src/certificate.cc | |
| parent | 0a5615c17edf6d9c51d9269c824d6caf71f710e5 (diff) | |
Cleanup: use dcp::LocalTime for certificate validity times.
Before we were using struct tm but not filling it all in, which
seems quite unpleasant.
Diffstat (limited to 'src/certificate.cc')
| -rw-r--r-- | src/certificate.cc | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/certificate.cc b/src/certificate.cc index 93f271ef..1e7714a3 100644 --- a/src/certificate.cc +++ b/src/certificate.cc @@ -329,29 +329,24 @@ Certificate::subject_organizational_unit_name () const static -struct tm +LocalTime convert_time (ASN1_TIME const * time) { - struct tm t; + LocalTime t; char const * s = (char const *) time->data; if (time->type == V_ASN1_UTCTIME) { - sscanf(s, "%2d%2d%2d%2d%2d%2d", &t.tm_year, &t.tm_mon, &t.tm_mday, &t.tm_hour, &t.tm_min, &t.tm_sec); - if (t.tm_year < 70) { - t.tm_year += 100; - } + return LocalTime::from_asn1_utc_time (s); } else if (time->type == V_ASN1_GENERALIZEDTIME) { - sscanf(s, "%4d%2d%2d%2d%2d%2d", &t.tm_year, &t.tm_mon, &t.tm_mday, &t.tm_hour, &t.tm_min, &t.tm_sec); - t.tm_year -= 1900; + return LocalTime::from_asn1_generalized_time (s); } - t.tm_mon--; - - return t; + DCP_ASSERT (false); + return {}; } -struct tm +LocalTime Certificate::not_before () const { DCP_ASSERT (_certificate); @@ -363,7 +358,7 @@ Certificate::not_before () const } -struct tm +LocalTime Certificate::not_after () const { DCP_ASSERT (_certificate); |
