[openssl-users] ASN1_TIME to time_t
Dr. Stephen Henson
steve at openssl.org
Wed Sep 6 16:23:26 UTC 2017
On Wed, Sep 06, 2017, Michael Wojcik wrote:
> > From: openssl-users [mailto:openssl-users-bounces at openssl.org] On Behalf
> > Of Dr. Stephen Henson
> > Sent: Wednesday, September 06, 2017 10:26
> > No but there is a a round about way of achieving the same result. The
> > ASN1_TIME_diff() function will determine the difference between two
> > ASN1_TIME structures and return the result as a number of days and seconds.
> > So if you set one to the epoch time you can then calculate the time_t from
> > the difference.
> That's almost certainly a much better approach than the one I described in my previous email.
> I assume ASN1_TIME_diff takes into account ASN.1 UTC Time versus Generalized Time, and timezone information. Though it wouldn't be hard to have a few different ASN1_TIME structures for the various permutations.
Yes ASN1_TIME corresponds to the ASN.1 Time structure which ia a choice of
UTCTime and GeneralizedTime it acts in an appropriate way depending on the
type that has been passed in. Timezones should be handled properly though
there was a recent bug fixed: timezones are only rarely encountered in
practice and not legal in many standards (e.g. RFC5280).
Dr Stephen N. Henson. OpenSSL project core developer.
Commercial tech support now available see: http://www.openssl.org
More information about the openssl-users