Merge pull request #5827 from wernerlewis/time_utc

Use ASN1 UTC tags for dates before 2000
This commit is contained in:
Dave Rodgman 2022-06-08 13:54:19 +01:00 committed by GitHub
commit 11930699f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 72 additions and 3 deletions

View file

@ -324,7 +324,7 @@ static int x509_write_time( unsigned char **p, unsigned char *start,
/*
* write MBEDTLS_ASN1_UTC_TIME if year < 2050 (2 bytes shorter)
*/
if( t[0] == '2' && t[1] == '0' && t[2] < '5' )
if( t[0] < '2' || ( t[0] == '2' && t[1] == '0' && t[2] < '5' ) )
{
MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_raw_buffer( p, start,
(const unsigned char *) t + 2,