Hi,
I have added a custom callback function for x509_crt_verify() which gets called for each certificate in the chain. I am only storing the thumbprint of my root certificate instead of whole certificate. Except the root certificate rest of the intermediate certificates would be validated through their respective parents as it happens right now. However for root certificate the verification would fail with the flags set to MBEDTLS_X509_BADCERT_NOT_TRUSTED
I plan to postpone the root certificate verification in the callback. Problem is even when I am able to confirm the root certificate is the one which is in my custom ca list the MBEDTLS_X509_BADCERT_NOT_TRUSTED flag can not be modified and my ssl handshake fails
Currently I have a workaround like this in x509_crt_verify_chain() function
if( parent == NULL )
{
#ifdef CALLBACK
*flags |= MBEDTLS_X509_BADCERT_MISSING;
#else
*flags |= MBEDTLS_X509_BADCERT_NOT_TRUSTED;
#endif
return( 0 );
}
Later in the callback I do root cert verification & if it fails I set
*flags = MBEDTLS_X509_BADCERT_NOT_TRUSTED
However I am not sure if this is the proper way & it does not introduce any security loophole
Would appreciate some suggestions…