- Corrected removal of leading '00:' in printing serial numbers in certificates and CRLs
diff --git a/library/x509parse.c b/library/x509parse.c
index 8341344..d49b643 100644
--- a/library/x509parse.c
+++ b/library/x509parse.c
@@ -2426,6 +2426,9 @@
for( i = 0; i < nr; i++ )
{
+ if( i == 0 && serial->p[i] == 0x0 )
+ continue;
+
ret = snprintf( p, n, "%02X%s",
serial->p[i], ( i < nr - 1 ) ? ":" : "" );
SAFE_SNPRINTF();
@@ -2589,7 +2592,7 @@
const x509_crl *crl )
{
int ret;
- size_t i, n, nr;
+ size_t n;
char *p;
const x509_crl_entry *entry;
@@ -2631,22 +2634,15 @@
prefix );
SAFE_SNPRINTF();
- nr = ( entry->serial.len <= 32 )
- ? entry->serial.len : 32;
+ ret = x509parse_serial_gets( p, n, &entry->serial);
+ SAFE_SNPRINTF();
- for( i = 0; i < nr; i++ )
- {
- ret = snprintf( p, n, "%02X%s",
- entry->serial.p[i], ( i < nr - 1 ) ? ":" : "" );
- SAFE_SNPRINTF();
- }
-
ret = snprintf( p, n, " revocation date: " \
"%04d-%02d-%02d %02d:%02d:%02d",
entry->revocation_date.year, entry->revocation_date.mon,
entry->revocation_date.day, entry->revocation_date.hour,
entry->revocation_date.min, entry->revocation_date.sec );
- SAFE_SNPRINTF();
+ SAFE_SNPRINTF();
entry = entry->next;
}