Adapt ssl_client2 to parse DER encoded test CRTs if PEM is disabled

This commit is contained in:
Hanno Becker 2019-02-01 08:15:06 +00:00
parent 38566ccbd5
commit bb676f7d32

View File

@ -1235,6 +1235,8 @@ int main( int argc, char *argv[] )
else else
#endif #endif
#if defined(MBEDTLS_CERTS_C) #if defined(MBEDTLS_CERTS_C)
{
#if defined(MBEDTLS_PEM_PARSE_C)
for( i = 0; mbedtls_test_cas[i] != NULL; i++ ) for( i = 0; mbedtls_test_cas[i] != NULL; i++ )
{ {
ret = mbedtls_x509_crt_parse( &cacert, ret = mbedtls_x509_crt_parse( &cacert,
@ -1243,12 +1245,23 @@ int main( int argc, char *argv[] )
if( ret != 0 ) if( ret != 0 )
break; break;
} }
if( ret == 0 )
#endif /* MBEDTLS_PEM_PARSE_C */
for( i = 0; mbedtls_test_cas_der[i] != NULL; i++ )
{
ret = mbedtls_x509_crt_parse_der( &cacert,
(const unsigned char *) mbedtls_test_cas_der[i],
mbedtls_test_cas_der_len[i] );
if( ret != 0 )
break;
}
}
#else #else
{ {
ret = 1; ret = 1;
mbedtls_printf( "MBEDTLS_CERTS_C not defined." ); mbedtls_printf( "MBEDTLS_CERTS_C not defined." );
} }
#endif #endif /* MBEDTLS_CERTS_C */
if( ret < 0 ) if( ret < 0 )
{ {
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n",