X509_CMP_TIME(3ossl)
π X509_CMP_TIME β the X509 time functions, bestie edition β¨
okay so this is from the <pink>3ossl</pink> manual β the OpenSSL girlies. it's literally all about comparing and adjusting ASN1_TIME values, and ngl it's lowkey iconic once you get it. let's go π«Ά
πΈ NAME πΈ
X509_cmp_time, X509_cmp_current_time, X509_cmp_timeframe, X509_time_adj, X509_time_adj_ex, X509_gmtime_adj β the X509 time functions. that's the whole squad π
π¦ SYNOPSIS π¦
int X509_cmp_time(const ASN1_TIME *asn1_time, time_t *in_tm);
int X509_cmp_current_time(const ASN1_TIME *asn1_time);
int X509_cmp_timeframe(const X509_VERIFY_PARAM *vpm,
const ASN1_TIME *start, const ASN1_TIME *end);
ASN1_TIME *X509_time_adj(ASN1_TIME *asn1_time, long offset_sec, time_t *in_tm);
ASN1_TIME *X509_time_adj_ex(ASN1_TIME *asn1_time, int offset_day, long
offset_sec, time_t *in_tm);
ASN1_TIME *X509_gmtime_adj(ASN1_TIME *asn1_time, long offset_sec);
π DESCRIPTION π
the comparing girlies β
X509_cmp_time()β compares theASN1_TIMEinasn1_timeagainst the time living inin_tm. that's it, that's the vibe.X509_cmp_current_time()β same energy, but it comparesasn1_timeagainst the current time, expressed astime_t. right here, right now, main character energy πX509_cmp_timeframe()β compares the given time period against the reference time that's chillin' inside the verification parametersvpm, but only ifvpmis notNULLand containsX509_V_FLAG_USE_CHECK_TIME. otherwise? the current time steps in as the reference time. slay π
the adjusting girlies β¨
X509_time_adj_ex()β sets theASN1_TIMEstructureasn1_timeto the timeoffset_dayandoffset_secafterin_tm. two offsets, double the fun πX509_time_adj()β sets theASN1_TIMEstructureasn1_timeto the timeoffset_secafterin_tm. β οΈ heads up bestie: this one can only handle second offsets up to the capacity oflong, so the newerX509_time_adj_ex()API should be preferred. it's giving deprecated-adjacent, iykyk πX509_gmtime_adj()β sets theASN1_TIMEstructureasn1_timeto the timeoffset_secafter the current time. it's literally equivalent to callingX509_time_adj()with the last parameter asNULL. no cap π
the rules that apply to everybody π
in both X509_time_adj_ex() and X509_time_adj(): if asn1_time is NULL, a new ASN1_TIME structure is allocated and returned. fresh out the box β¨
in all the methods: if in_tm is NULL, the current time is used, expressed as time_t. convenient or what π
and like...asn1_timemust satisfy theASN1_TIMEformat mandated by RFC 5280. so its format has to be eitherYYMMDDHHMMSSZorYYYYMMDDHHMMSSZ. no exceptions, no vibes-based formatting, periodt π
π BUGS π
okay this is the part where we all gasp π
unlike many standard comparison functions, X509_cmp_time() and X509_cmp_current_time() return 0 on error. so like... zero isn't always "equal", sometimes it's "girl something went wrong". be careful out there π
π₯ RETURN VALUES π₯
X509_cmp_time() and X509_cmp_current_time() return -1 if asn1_time is earlier than, or equal to, in_tm (resp. the current time), and 1 otherwise. and yes β they return 0 on error. we been knew π
X509_cmp_timeframe() returns 0 if vpm is not NULL and the verification parameters do not contain X509_V_FLAG_USE_CHECK_TIME but do contain X509_V_FLAG_NO_CHECK_TIME. otherwise:
- returns
1if the end time is notNULLand the reference time (determined as stated above, bestie, keep up β¨) is past the end time - returns
-1if the start time is notNULLand the reference time is before - else returns
0to indicate that the reference time is in range (implying that the end time is not before the start time if both are present) π
X509_time_adj(), X509_time_adj_ex() and X509_gmtime_adj() return a pointer to the updated ASN1_TIME structure, and NULL on error. simple as π¦
πΈ HISTORY πΈ
X509_cmp_timeframe() was added in OpenSSL 3.0. a whole new era π
π COPYRIGHT π
Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
okay that's the whole page bestie, you ate that π«Άβ¨
version 3.5.6 Β· dated 2026-04-07 Β· X509_CMP_TIME(3ossl) β mwah, go forth and compare your times responsibly πππ¦
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms