Re: ASN1_TIME to time_t

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> From: openssl-users [mailto:openssl-users-bounces@xxxxxxxxxxx] On Behalf Of Dmitry Belyavsky
> Sent: Wednesday, September 06, 2017 04:12

> Is there a way to convert ASN1_TIME to time_t or smth compatible? Quick googling does not show good results.

We just implemented it ourselves, by parsing the data field of the (1.0.2) OpenSSL ASN1_TIME structure into a struct tm and using mktime.

That's not ideal, since it's looking at an internal representation. Also, for some reason, 1.0.2 seems to keep the year as a two-digit value for ASN.1 UTC Time, with a window centered on 1970, while it uses a 4-digit year for ASN.1 Generalized Time. The code handles that but it makes me nervous - it's the sort of internal detail that seems likely to change.

struct tm is local time, so you need to adjust for timezone. With Generalized Time you need to parse the offset from UTC; then you adjust your struct tm based on the difference between the ASN.1 time's offset and your local offset.

I should really review that code at some point. But for now it appears to work.

Michael Wojcik 
Distinguished Engineer, Micro Focus 



-- 
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux