ssl: add pre-verify callback setter test with no callback set

This commit is contained in:
Andrzej Kurek 2018-04-03 08:26:29 -04:00
parent 50ef31218b
commit 7601686acb
2 changed files with 10 additions and 4 deletions

View File

@ -59,4 +59,7 @@ SSL SET_HOSTNAME memory leak: call ssl_set_hostname twice
ssl_set_hostname_twice:"server0":"server1" ssl_set_hostname_twice:"server0":"server1"
SSL preverify callback: basic SSL preverify callback: basic
ssl_preverifycb:"data_files/server1.crt" ssl_preverifycb:"data_files/server1.crt":1:1
SSL preverify callback: no callback
ssl_preverifycb:"data_files/server1.crt":0:0

View File

@ -83,7 +83,7 @@ void ssl_set_hostname_twice( char *hostname0, char *hostname1 )
/* END_CASE */ /* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_KEY_EXCHANGE_RSA_ENABLED:MBEDTLS_AES_C:MBEDTLS_SHA256_C:MBEDTLS_CIPHER_MODE_CBC */ /* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_KEY_EXCHANGE_RSA_ENABLED:MBEDTLS_AES_C:MBEDTLS_SHA256_C:MBEDTLS_CIPHER_MODE_CBC */
void ssl_preverifycb( char *crt_file ) void ssl_preverifycb( char *crt_file, int set_callback, int data_value )
{ {
mbedtls_ssl_context ssl; mbedtls_ssl_context ssl;
mbedtls_ssl_config conf; mbedtls_ssl_config conf;
@ -112,10 +112,13 @@ void ssl_preverifycb( char *crt_file )
/* Read in the certificate record, and check it calls the pre-verify callback */ /* Read in the certificate record, and check it calls the pre-verify callback */
conf.endpoint = MBEDTLS_SSL_IS_CLIENT; conf.endpoint = MBEDTLS_SSL_IS_CLIENT;
mbedtls_ssl_conf_pre_verify( &conf, pre_vrfy_fn, (void*)&pre_vrfy_data ); if( set_callback != 0 )
{
mbedtls_ssl_conf_pre_verify( &conf, pre_vrfy_fn, (void*)&pre_vrfy_data );
}
TEST_ASSERT( mbedtls_ssl_parse_certificate( &ssl ) == 0 ); TEST_ASSERT( mbedtls_ssl_parse_certificate( &ssl ) == 0 );
TEST_ASSERT( pre_vrfy_data != 0 ); TEST_ASSERT( pre_vrfy_data == data_value );
mbedtls_ssl_free( &ssl ); mbedtls_ssl_free( &ssl );
mbedtls_ssl_config_free( &conf ); mbedtls_ssl_config_free( &conf );