diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2009-03-09 13:59:07 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2009-03-09 13:59:07 +0000 |
commit | 33ab2e31f380888dc3b8d8ba7da6ded1ae51b0d5 (patch) | |
tree | ed9cd617104677c021c4a618180d9a336b1160c9 /crypto/asn1 | |
parent | bb7ccdfbe22aac18b26278d862050fbfee9d1b79 (diff) |
PR: 1854
Submitted by: Oliver Martin <oliver@volatilevoid.net>
Reviewed by: steve@openssl.org
Support GeneralizedTime in ca utility.
Diffstat (limited to 'crypto/asn1')
-rw-r--r-- | crypto/asn1/a_time.c | 22 | ||||
-rw-r--r-- | crypto/asn1/asn1.h | 1 |
2 files changed, 23 insertions, 0 deletions
diff --git a/crypto/asn1/a_time.c b/crypto/asn1/a_time.c index 577e263402..576de5805a 100644 --- a/crypto/asn1/a_time.c +++ b/crypto/asn1/a_time.c @@ -173,3 +173,25 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZE return ret; } + +int ASN1_TIME_set_string(ASN1_TIME *s, const char *str) + { + ASN1_TIME t; + + t.length = strlen(str); + t.data = (unsigned char *)str; + + t.type = V_ASN1_UTCTIME; + + if (!ASN1_TIME_check(&t)) + { + t.type = V_ASN1_GENERALIZEDTIME; + if (!ASN1_TIME_check(&t)) + return 0; + } + + if (s && !ASN1_STRING_copy((ASN1_STRING *)s, (ASN1_STRING *)&t)) + return 0; + + return 1; + } diff --git a/crypto/asn1/asn1.h b/crypto/asn1/asn1.h index 26c3a48c6b..2c0e05ba0f 100644 --- a/crypto/asn1/asn1.h +++ b/crypto/asn1/asn1.h @@ -885,6 +885,7 @@ ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s,time_t t, int offset_day, long offset_sec); int ASN1_TIME_check(ASN1_TIME *t); ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME **out); +int ASN1_TIME_set_string(ASN1_TIME *s, const char *str); int i2d_ASN1_SET(STACK_OF(BLOCK) *a, unsigned char **pp, i2d_of_void *i2d, int ex_tag, int ex_class, |