Browse Source

[crypto] Accept UTCTime/GeneralizedTime with no "seconds" field

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 years ago
parent
commit
f20c3742e7
1 changed files with 6 additions and 0 deletions
  1. 6
    0
      src/crypto/asn1.c

+ 6
- 0
src/crypto/asn1.c View File

@@ -655,10 +655,16 @@ int asn1_generalized_time ( const struct asn1_cursor *cursor, time_t *time ) {
655 655
 	}
656 656
 
657 657
 	/* Parse digit string a pair at a time */
658
+	memset ( &pairs, 0, sizeof ( pairs ) );
658 659
 	data = contents.data;
659 660
 	remaining = contents.len;
660 661
 	for ( i = ( have_century ? 0 : 1 ) ; i < sizeof ( pairs.raw ) ; i++ ) {
661 662
 		if ( remaining < 2 ) {
663
+			/* Some certificates violate the X.509 RFC by
664
+			 * omitting the "seconds" value.
665
+			 */
666
+			if ( i == ( sizeof ( pairs.raw ) - 1 ) )
667
+				break;
662 668
 			DBGC ( cursor, "ASN1 %p invalid time:\n", cursor );
663 669
 			DBGC_HDA ( cursor, 0, cursor->data, cursor->len );
664 670
 			return -EINVAL_ASN1_TIME;

Loading…
Cancel
Save