title: mbedtls DER formatted certificate chain verification
body: <p>I am trying to verify a certificate chain using mbedTLS version 2.16.2. The certificate chain in DER format as individual files.
  The PKI is simple as three levels (1) Root_CA (2) Intermediate_CA (3) Device_CERT</p>
  <p>I could able to verify the certificates using <code>openssl verify ---</code> command ; but with below program, the certificate verification fails with  <code>Error: -0x2700; flag: 8</code></p>
  <p>Am I verifying the cert chain (DER formatted files) the correct way?</p>
  <pre><code>void verify_cert_chain_driver( void )
  {
     int32_t r = -1; uint32_t flags = 0;
  
     mbedtls_x509_crt ca, chain;
  
     do{
  
        r = parse_from_file( &amp;ca, &quot;x509-root-ca.der&quot; );
        if( EXIT_SUCCESS != r )    break;
        
        r = parse_from_file( &amp;chain, &quot;x509-intermediate-ca.der&quot; );
        if( EXIT_SUCCESS != r )    break;
  
        r = parse_from_file( &amp;chain, &quot;x509-dev-cert.der&quot; );
        if( EXIT_SUCCESS != r )    break;
  
        r = mbedtls_x509_crt_verify( &amp;chain, &amp;ca, NULL, NULL, &amp;flags, NULL, NULL );
        if( EXIT_SUCCESS != r )    break;
  
        printf( &quot;Verify OK\r\n&quot; );
     }while(0);
  
     if( 0 != r )  printf( &quot;Error: 0x%04x; flag: %u\r\n&quot;, r, flags );
  }
  </code></pre>