[openssl-users] ASN1_TIME to time_t
Dr. Stephen Henson
steve at openssl.org
Wed Sep 6 14:26:19 UTC 2017
On Wed, Sep 06, 2017, Dmitry Belyavsky wrote:
> Dear Matt,
> On Wed, Sep 6, 2017 at 11:16 AM, Matt Caswell <matt at openssl.org> wrote:
> > On 06/09/17 09:12, Dmitry Belyavsky wrote:
> > > Hello,
> > >
> > > Is there a way to convert ASN1_TIME to time_t or smth compatible? Quick
> > > googling does not show good results.
> > In master you can use ASN1_TIME_to_tm() which will give you a struct tm.
> > Not available in released versions yet though.
> Is it implementable via API in 1.0.2?
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
Dr Stephen N. Henson. OpenSSL project core developer.
Commercial tech support now available see: http://www.openssl.org
More information about the openssl-users