summaryrefslogtreecommitdiffstats
path: root/crypto/asn1/a_time.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2008-10-07 22:55:27 +0000
committerDr. Stephen Henson <steve@openssl.org>2008-10-07 22:55:27 +0000
commit87d3a0cd9006f67fed0d3335d8b1c5ab94a26f8f (patch)
tree1e3f5000326191e669df486f0a0a471aed765df6 /crypto/asn1/a_time.c
parent1e369b375eaae43e2ec186f067905a0fab4bd6f1 (diff)
Experimental new date handling routines. These fix issues with X509_time_adj()
and should avoid any OS date limitations such as the year 2038 bug.
Diffstat (limited to 'crypto/asn1/a_time.c')
-rw-r--r--crypto/asn1/a_time.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/crypto/asn1/a_time.c b/crypto/asn1/a_time.c
index 159681fbcb..577e263402 100644
--- a/crypto/asn1/a_time.c
+++ b/crypto/asn1/a_time.c
@@ -100,6 +100,12 @@ int i2d_ASN1_TIME(ASN1_TIME *a, unsigned char **pp)
ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t)
{
+ return ASN1_TIME_adj(s, t, 0, 0);
+ }
+
+ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t,
+ int offset_day, long offset_sec)
+ {
struct tm *ts;
struct tm data;
@@ -109,9 +115,14 @@ ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t)
ASN1err(ASN1_F_ASN1_TIME_SET, ASN1_R_ERROR_GETTING_TIME);
return NULL;
}
+ if (offset_day || offset_sec)
+ {
+ if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
+ return NULL;
+ }
if((ts->tm_year >= 50) && (ts->tm_year < 150))
- return ASN1_UTCTIME_set(s, t);
- return ASN1_GENERALIZEDTIME_set(s,t);
+ return ASN1_UTCTIME_adj(s, t, offset_day, offset_sec);
+ return ASN1_GENERALIZEDTIME_adj(s, t, offset_day, offset_sec);
}
int ASN1_TIME_check(ASN1_TIME *t)