Make use of CRT acquire/release in mbedtls_debug_print_crt()

This commit is contained in:
Hanno Becker 2019-02-26 16:46:04 +00:00
parent 5c03058bbc
commit 6cb5f86dac

View file

@ -382,6 +382,8 @@ void mbedtls_debug_print_crt( const mbedtls_ssl_context *ssl, int level,
while( crt != NULL )
{
int ret;
mbedtls_pk_context *pk;
char buf[1024];
mbedtls_snprintf( str, sizeof( str ), "%s #%d:\n", text, ++i );
@ -390,7 +392,17 @@ void mbedtls_debug_print_crt( const mbedtls_ssl_context *ssl, int level,
mbedtls_x509_crt_info( buf, sizeof( buf ) - 1, "", crt );
debug_print_line_by_line( ssl, level, file, line, buf );
debug_print_pk( ssl, level, file, line, "crt->", &crt->pk );
ret = mbedtls_x509_crt_pk_acquire( crt, &pk );
if( ret != 0 )
{
mbedtls_snprintf( str, sizeof( str ),
"mbedtls_x509_crt_pk_acquire() failed with -%#04x\n",
-ret );
debug_send_line( ssl, level, file, line, str );
return;
}
debug_print_pk( ssl, level, file, line, "crt->", pk );
mbedtls_x509_crt_pk_release( crt, pk );
crt = crt->next;
}