aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/asn1
diff options
context:
space:
mode:
authorBen Laurie <ben@openssl.org>2000-05-14 12:39:53 +0000
committerBen Laurie <ben@openssl.org>2000-05-14 12:39:53 +0000
commitfd73a2121ced27ecf1491246b98c07b8e20dc005 (patch)
tree979325e65068c76597a0fc3e4164a6a645501541 /crypto/asn1
parent50e4e9283d30a3d70aa7b6091196674155c88005 (diff)
downloadopenssl-fd73a2121ced27ecf1491246b98c07b8e20dc005.tar.gz
Allow UTCTIME objects to be retrieved. Check for imminent cert expiry.
Diffstat (limited to 'crypto/asn1')
-rw-r--r--crypto/asn1/a_utctm.c29
-rw-r--r--crypto/asn1/asn1.h1
2 files changed, 30 insertions, 0 deletions
diff --git a/crypto/asn1/a_utctm.c b/crypto/asn1/a_utctm.c
index 07565974e3..e8d2836c58 100644
--- a/crypto/asn1/a_utctm.c
+++ b/crypto/asn1/a_utctm.c
@@ -264,3 +264,32 @@ ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)
#endif
return(s);
}
+
+time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s)
+ {
+ struct tm tm;
+ int offset;
+
+ memset(&tm,'\0',sizeof tm);
+
+#define g2(p) (((p)[0]-'0')*10+(p)[1]-'0')
+ tm.tm_year=g2(s->data);
+ if(tm.tm_year < 50)
+ tm.tm_year+=100;
+ tm.tm_mon=g2(s->data+2)-1;
+ tm.tm_mday=g2(s->data+4);
+ tm.tm_hour=g2(s->data+6);
+ tm.tm_min=g2(s->data+8);
+ tm.tm_sec=g2(s->data+10);
+ if(s->data[12] == 'Z')
+ offset=0;
+ else
+ {
+ offset=g2(s->data+13)*60+g2(s->data+15);
+ if(s->data[12] == '-')
+ offset= -offset;
+ }
+#undef g2
+
+ return timegm(&tm)-offset*60;
+ }
diff --git a/crypto/asn1/asn1.h b/crypto/asn1/asn1.h
index 8cf317640e..f340ed41df 100644
--- a/crypto/asn1/asn1.h
+++ b/crypto/asn1/asn1.h
@@ -579,6 +579,7 @@ ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a,unsigned char **pp,
int ASN1_UTCTIME_check(ASN1_UTCTIME *a);
ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t);
int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, char *str);
+time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s);
int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a);
ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t);