mbedtls_x509_crt_parse_der_with_ext_cb improvement

Continue parsing when the callback fails to parse a non critical
exception. Also document the behaviour more extensively and pass
the callback error code to the caller unaltered.

See https://github.com/ARMmbed/mbedtls/pull/3243#discussion_r432630548
and https://github.com/ARMmbed/mbedtls/pull/3243#discussion_r432630968

Signed-off-by: Nicola Di Lieto <nicola.dilieto@gmail.com>
This commit is contained in:
Nicola Di Lieto 2020-05-29 22:46:56 +02:00
parent 5659e7e889
commit 565b52bb72
2 changed files with 15 additions and 5 deletions

View file

@ -961,8 +961,8 @@ static int x509_get_crt_ext( unsigned char **p,
if( cb != NULL )
{
ret = cb( p_ctx, crt, &extn_oid, is_critical, *p, end_ext_octet );
if( ret != 0 )
return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret );
if( ret != 0 && is_critical )
return( ret );
*p = end_ext_octet;
continue;
}