summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbeck <>2017-05-08 21:12:36 +0000
committerbeck <>2017-05-08 21:12:36 +0000
commit3fc4fca12d585e23e74c7b750445d31c96380ba0 (patch)
treec2a84a9bf1512c5f9038112fe632ff17ce51221b
parenteb05f97e0974a99799b842de278f502507776c43 (diff)
downloadopenbsd-3fc4fca12d585e23e74c7b750445d31c96380ba0.tar.gz
openbsd-3fc4fca12d585e23e74c7b750445d31c96380ba0.tar.bz2
openbsd-3fc4fca12d585e23e74c7b750445d31c96380ba0.zip
simplify startdate/enddate validation
ok jsing@
-rw-r--r--src/usr.bin/openssl/ca.c32
1 files changed, 5 insertions, 27 deletions
diff --git a/src/usr.bin/openssl/ca.c b/src/usr.bin/openssl/ca.c
index 9ed7c59caa..5414a921d4 100644
--- a/src/usr.bin/openssl/ca.c
+++ b/src/usr.bin/openssl/ca.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ca.c,v 1.24 2017/05/04 12:36:13 beck Exp $ */ 1/* $OpenBSD: ca.c,v 1.25 2017/05/08 21:12:36 beck Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -218,37 +218,15 @@ static int msie_hack = 0;
218static int 218static int
219setCertificateTime(ASN1_TIME *x509time, char *timestring) 219setCertificateTime(ASN1_TIME *x509time, char *timestring)
220{ 220{
221 struct tm tm1, tm2; 221 struct tm tm1;
222 char *rfctime = timestring;
223 int type;
224
225 memset(&tm1, 0, sizeof(tm1)); 222 memset(&tm1, 0, sizeof(tm1));
226 memset(&tm2, 0, sizeof(tm2)); 223 if (ASN1_time_parse(timestring, strlen(timestring), &tm1, 0) == -1)
227 type = ASN1_time_parse(timestring, strlen(timestring), &tm1, 0);
228 if (type == -1) {
229 return (-1); 224 return (-1);
230 } 225 if (!ASN1_TIME_set_tm(x509time, &tm1))
231
232 /* RFC 5280 section 4.1.2.5 */
233 if (tm1.tm_year < 150 && type != V_ASN1_UTCTIME) {
234 if (strlen(timestring) == 15) {
235 /* Fix date if possible */
236 rfctime = timestring + 2;
237 type = ASN1_time_parse(rfctime, strlen(rfctime),
238 &tm2, 0);
239 if (type != V_ASN1_UTCTIME ||
240 tm1.tm_year != tm2.tm_year)
241 return (-1);
242 } else
243 return (-1);
244 }
245 if (tm1.tm_year >= 150 && type != V_ASN1_GENERALIZEDTIME)
246 return (-1); 226 return (-1);
247 ASN1_TIME_set_string(x509time, rfctime); 227 return 0;
248 return (0);
249} 228}
250 229
251
252int 230int
253ca_main(int argc, char **argv) 231ca_main(int argc, char **argv)
254{ 232{