Don't break debug messages

This commit is contained in:
Hanno Becker 2017-10-27 13:43:58 +01:00
parent 8149321fed
commit df4180a235
3 changed files with 53 additions and 54 deletions

View File

@ -478,8 +478,7 @@ void idle( mbedtls_ssl_context *ssl,
* if data is still pending to be processed. */ * if data is still pending to be processed. */
if( mbedtls_ssl_check_pending( ssl ) != 0 ) if( mbedtls_ssl_check_pending( ssl ) != 0 )
{ {
MBEDTLS_SSL_DEBUG_MSG( 1, ( "WARNING: Data still pending, " MBEDTLS_SSL_DEBUG_MSG( 1, ( "WARNING: Data still pending, but idling requested!" ) );
"but idling requested!" ) );
} }
MBEDTLS_SSL_DEBUG_MSG( 3, ( "idle, waiting for event... " ) ); MBEDTLS_SSL_DEBUG_MSG( 3, ( "idle, waiting for event... " ) );
@ -504,8 +503,8 @@ void idle( mbedtls_ssl_context *ssl,
if( poll_type != 0 && if( poll_type != 0 &&
mbedtls_net_poll( fd, poll_type, 0 ) == poll_type ) mbedtls_net_poll( fd, poll_type, 0 ) == poll_type )
{ {
MBEDTLS_SSL_DEBUG_MSG( 3, ( "[%lu ms] net_context signals data - " MBEDTLS_SSL_DEBUG_MSG( 3, ( "[%lu ms] net_context signals data - continue",
"continue", time_elapsed ) ); time_elapsed ) );
break; break;
} }
} }
@ -960,8 +959,7 @@ int main( int argc, char *argv[] )
* refers to the underlying net_context. */ * refers to the underlying net_context. */
if( opt.event == 1 && opt.nbio != 1 ) if( opt.event == 1 && opt.nbio != 1 )
{ {
mbedtls_printf( "Warning: event-driven IO mandates nbio=1" mbedtls_printf( "Warning: event-driven IO mandates nbio=1 - overwrite\n" );
" - overwrite\n" );
opt.nbio = 1; opt.nbio = 1;
} }
@ -1236,8 +1234,8 @@ int main( int argc, char *argv[] )
#endif #endif
if( ret != 0 ) if( ret != 0 )
{ {
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse " mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n",
"returned -0x%x\n\n", -ret ); -ret );
goto exit; goto exit;
} }
@ -1261,8 +1259,8 @@ int main( int argc, char *argv[] )
#endif #endif
if( ret != 0 ) if( ret != 0 )
{ {
mbedtls_printf( " failed\n ! mbedtls_pk_parse_key " mbedtls_printf( " failed\n ! mbedtls_pk_parse_key returned -0x%x\n\n",
"returned -0x%x\n\n", -ret ); -ret );
goto exit; goto exit;
} }
@ -1285,8 +1283,8 @@ int main( int argc, char *argv[] )
opt.transport == MBEDTLS_SSL_TRANSPORT_STREAM ? opt.transport == MBEDTLS_SSL_TRANSPORT_STREAM ?
MBEDTLS_NET_PROTO_TCP : MBEDTLS_NET_PROTO_UDP ) ) != 0 ) MBEDTLS_NET_PROTO_TCP : MBEDTLS_NET_PROTO_UDP ) ) != 0 )
{ {
mbedtls_printf( " failed\n ! mbedtls_net_connect " mbedtls_printf( " failed\n ! mbedtls_net_connect returned -0x%x\n\n",
"returned -0x%x\n\n", -ret ); -ret );
goto exit; goto exit;
} }
@ -1296,8 +1294,8 @@ int main( int argc, char *argv[] )
ret = mbedtls_net_set_block( &server_fd ); ret = mbedtls_net_set_block( &server_fd );
if( ret != 0 ) if( ret != 0 )
{ {
mbedtls_printf( " failed\n ! net_set_(non)block() " mbedtls_printf( " failed\n ! net_set_(non)block() returned -0x%x\n\n",
"returned -0x%x\n\n", -ret ); -ret );
goto exit; goto exit;
} }
@ -1314,8 +1312,8 @@ int main( int argc, char *argv[] )
opt.transport, opt.transport,
MBEDTLS_SSL_PRESET_DEFAULT ) ) != 0 ) MBEDTLS_SSL_PRESET_DEFAULT ) ) != 0 )
{ {
mbedtls_printf( " failed\n ! mbedtls_ssl_config_defaults " mbedtls_printf( " failed\n ! mbedtls_ssl_config_defaults returned -0x%x\n\n",
"returned -0x%x\n\n", -ret ); -ret );
goto exit; goto exit;
} }
@ -1345,8 +1343,8 @@ int main( int argc, char *argv[] )
#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
if( ( ret = mbedtls_ssl_conf_max_frag_len( &conf, opt.mfl_code ) ) != 0 ) if( ( ret = mbedtls_ssl_conf_max_frag_len( &conf, opt.mfl_code ) ) != 0 )
{ {
mbedtls_printf( " failed\n ! mbedtls_ssl_conf_max_frag_len " mbedtls_printf( " failed\n ! mbedtls_ssl_conf_max_frag_len returned %d\n\n",
"returned %d\n\n", ret ); ret );
goto exit; goto exit;
} }
#endif #endif
@ -1382,8 +1380,8 @@ int main( int argc, char *argv[] )
if( opt.alpn_string != NULL ) if( opt.alpn_string != NULL )
if( ( ret = mbedtls_ssl_conf_alpn_protocols( &conf, alpn_list ) ) != 0 ) if( ( ret = mbedtls_ssl_conf_alpn_protocols( &conf, alpn_list ) ) != 0 )
{ {
mbedtls_printf( " failed\n ! mbedtls_ssl_conf_alpn_protocols " mbedtls_printf( " failed\n ! mbedtls_ssl_conf_alpn_protocols returned %d\n\n",
"returned %d\n\n", ret ); ret );
goto exit; goto exit;
} }
#endif #endif
@ -1422,8 +1420,8 @@ int main( int argc, char *argv[] )
{ {
if( ( ret = mbedtls_ssl_conf_own_cert( &conf, &clicert, &pkey ) ) != 0 ) if( ( ret = mbedtls_ssl_conf_own_cert( &conf, &clicert, &pkey ) ) != 0 )
{ {
mbedtls_printf( " failed\n ! mbedtls_ssl_conf_own_cert " mbedtls_printf( " failed\n ! mbedtls_ssl_conf_own_cert returned %d\n\n",
"returned %d\n\n", ret ); ret );
goto exit; goto exit;
} }
} }
@ -1442,8 +1440,8 @@ int main( int argc, char *argv[] )
(const unsigned char *) opt.psk_identity, (const unsigned char *) opt.psk_identity,
strlen( opt.psk_identity ) ) ) != 0 ) strlen( opt.psk_identity ) ) ) != 0 )
{ {
mbedtls_printf( " failed\n ! mbedtls_ssl_conf_psk " mbedtls_printf( " failed\n ! mbedtls_ssl_conf_psk returned %d\n\n",
"returned %d\n\n", ret ); ret );
goto exit; goto exit;
} }
#endif #endif
@ -1463,16 +1461,16 @@ int main( int argc, char *argv[] )
if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 ) if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 )
{ {
mbedtls_printf( " failed\n ! mbedtls_ssl_setup " mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned -0x%x\n\n",
"returned -0x%x\n\n", -ret ); -ret );
goto exit; goto exit;
} }
#if defined(MBEDTLS_X509_CRT_PARSE_C) #if defined(MBEDTLS_X509_CRT_PARSE_C)
if( ( ret = mbedtls_ssl_set_hostname( &ssl, opt.server_name ) ) != 0 ) if( ( ret = mbedtls_ssl_set_hostname( &ssl, opt.server_name ) ) != 0 )
{ {
mbedtls_printf( " failed\n ! mbedtls_ssl_set_hostname " mbedtls_printf( " failed\n ! mbedtls_ssl_set_hostname returned %d\n\n",
"returned %d\n\n", ret ); ret );
goto exit; goto exit;
} }
#endif #endif
@ -1484,8 +1482,8 @@ int main( int argc, char *argv[] )
(const unsigned char *) opt.ecjpake_pw, (const unsigned char *) opt.ecjpake_pw,
strlen( opt.ecjpake_pw ) ) ) != 0 ) strlen( opt.ecjpake_pw ) ) ) != 0 )
{ {
mbedtls_printf( " failed\n ! mbedtls_ssl_set_hs_ecjpake_password " mbedtls_printf( " failed\n ! mbedtls_ssl_set_hs_ecjpake_password returned %d\n\n",
"returned %d\n\n", ret ); ret );
goto exit; goto exit;
} }
} }
@ -1516,8 +1514,8 @@ int main( int argc, char *argv[] )
if( ret != MBEDTLS_ERR_SSL_WANT_READ && if( ret != MBEDTLS_ERR_SSL_WANT_READ &&
ret != MBEDTLS_ERR_SSL_WANT_WRITE ) ret != MBEDTLS_ERR_SSL_WANT_WRITE )
{ {
mbedtls_printf( " failed\n ! mbedtls_ssl_handshake " mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n",
"returned -0x%x\n", -ret ); -ret );
if( ret == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED ) if( ret == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED )
mbedtls_printf( mbedtls_printf(
" Unable to verify the server's certificate. " " Unable to verify the server's certificate. "
@ -1571,8 +1569,8 @@ int main( int argc, char *argv[] )
if( ( ret = mbedtls_ssl_get_session( &ssl, &saved_session ) ) != 0 ) if( ( ret = mbedtls_ssl_get_session( &ssl, &saved_session ) ) != 0 )
{ {
mbedtls_printf( " failed\n ! mbedtls_ssl_get_session " mbedtls_printf( " failed\n ! mbedtls_ssl_get_session returned -0x%x\n\n",
"returned -0x%x\n\n", -ret ); -ret );
goto exit; goto exit;
} }
@ -1622,8 +1620,8 @@ int main( int argc, char *argv[] )
if( ret != MBEDTLS_ERR_SSL_WANT_READ && if( ret != MBEDTLS_ERR_SSL_WANT_READ &&
ret != MBEDTLS_ERR_SSL_WANT_WRITE ) ret != MBEDTLS_ERR_SSL_WANT_WRITE )
{ {
mbedtls_printf( " failed\n ! mbedtls_ssl_renegotiate " mbedtls_printf( " failed\n ! mbedtls_ssl_renegotiate returned %d\n\n",
"returned %d\n\n", ret ); ret );
goto exit; goto exit;
} }
@ -1686,8 +1684,8 @@ send_request:
if( ret != MBEDTLS_ERR_SSL_WANT_READ && if( ret != MBEDTLS_ERR_SSL_WANT_READ &&
ret != MBEDTLS_ERR_SSL_WANT_WRITE ) ret != MBEDTLS_ERR_SSL_WANT_WRITE )
{ {
mbedtls_printf( " failed\n ! mbedtls_ssl_write " mbedtls_printf( " failed\n ! mbedtls_ssl_write returned -0x%x\n\n",
"returned -0x%x\n\n", -ret ); -ret );
goto exit; goto exit;
} }
@ -1726,8 +1724,8 @@ send_request:
if( ret < 0 ) if( ret < 0 )
{ {
mbedtls_printf( " failed\n ! mbedtls_ssl_write " mbedtls_printf( " failed\n ! mbedtls_ssl_write returned %d\n\n",
"returned %d\n\n", ret ); ret );
goto exit; goto exit;
} }

View File

@ -1427,8 +1427,7 @@ int main( int argc, char *argv[] )
* refers to the underlying net_context. */ * refers to the underlying net_context. */
if( opt.event == 1 && opt.nbio != 1 ) if( opt.event == 1 && opt.nbio != 1 )
{ {
mbedtls_printf( "Warning: event-driven IO mandates nbio=1" mbedtls_printf( "Warning: event-driven IO mandates nbio=1 - overwrite\n" );
" - overwrite\n" );
opt.nbio = 1; opt.nbio = 1;
} }
@ -1733,7 +1732,7 @@ int main( int argc, char *argv[] )
if( ( ret = mbedtls_pk_parse_keyfile( &pkey2, opt.key_file2, "" ) ) != 0 ) if( ( ret = mbedtls_pk_parse_keyfile( &pkey2, opt.key_file2, "" ) ) != 0 )
{ {
mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile(2) returned -0x%x\n\n", mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile(2) returned -0x%x\n\n",
-ret ); -ret );
goto exit; goto exit;
} }
} }
@ -1751,8 +1750,7 @@ int main( int argc, char *argv[] )
strcmp( opt.key_file2, "none" ) != 0 ) strcmp( opt.key_file2, "none" ) != 0 )
{ {
#if !defined(MBEDTLS_CERTS_C) #if !defined(MBEDTLS_CERTS_C)
mbedtls_printf( "Not certificated or key provided, and \n" mbedtls_printf( "Not certificated or key provided, and \nMBEDTLS_CERTS_C not defined!\n" );
"MBEDTLS_CERTS_C not defined!\n" );
goto exit; goto exit;
#else #else
#if defined(MBEDTLS_RSA_C) #if defined(MBEDTLS_RSA_C)
@ -1760,14 +1758,16 @@ int main( int argc, char *argv[] )
(const unsigned char *) mbedtls_test_srv_crt_rsa, (const unsigned char *) mbedtls_test_srv_crt_rsa,
mbedtls_test_srv_crt_rsa_len ) ) != 0 ) mbedtls_test_srv_crt_rsa_len ) ) != 0 )
{ {
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", -ret ); mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n",
-ret );
goto exit; goto exit;
} }
if( ( ret = mbedtls_pk_parse_key( &pkey, if( ( ret = mbedtls_pk_parse_key( &pkey,
(const unsigned char *) mbedtls_test_srv_key_rsa, (const unsigned char *) mbedtls_test_srv_key_rsa,
mbedtls_test_srv_key_rsa_len, NULL, 0 ) ) != 0 ) mbedtls_test_srv_key_rsa_len, NULL, 0 ) ) != 0 )
{ {
mbedtls_printf( " failed\n ! mbedtls_pk_parse_key returned -0x%x\n\n", -ret ); mbedtls_printf( " failed\n ! mbedtls_pk_parse_key returned -0x%x\n\n",
-ret );
goto exit; goto exit;
} }
key_cert_init = 2; key_cert_init = 2;
@ -1777,14 +1777,16 @@ int main( int argc, char *argv[] )
(const unsigned char *) mbedtls_test_srv_crt_ec, (const unsigned char *) mbedtls_test_srv_crt_ec,
mbedtls_test_srv_crt_ec_len ) ) != 0 ) mbedtls_test_srv_crt_ec_len ) ) != 0 )
{ {
mbedtls_printf( " failed\n ! x509_crt_parse2 returned -0x%x\n\n", -ret ); mbedtls_printf( " failed\n ! x509_crt_parse2 returned -0x%x\n\n",
-ret );
goto exit; goto exit;
} }
if( ( ret = mbedtls_pk_parse_key( &pkey2, if( ( ret = mbedtls_pk_parse_key( &pkey2,
(const unsigned char *) mbedtls_test_srv_key_ec, (const unsigned char *) mbedtls_test_srv_key_ec,
mbedtls_test_srv_key_ec_len, NULL, 0 ) ) != 0 ) mbedtls_test_srv_key_ec_len, NULL, 0 ) ) != 0 )
{ {
mbedtls_printf( " failed\n ! pk_parse_key2 returned -0x%x\n\n", -ret ); mbedtls_printf( " failed\n ! pk_parse_key2 returned -0x%x\n\n",
-ret );
goto exit; goto exit;
} }
key_cert_init2 = 2; key_cert_init2 = 2;
@ -2190,8 +2192,8 @@ reset:
if( ( ret = mbedtls_ssl_set_client_transport_id( &ssl, if( ( ret = mbedtls_ssl_set_client_transport_id( &ssl,
client_ip, cliip_len ) ) != 0 ) client_ip, cliip_len ) ) != 0 )
{ {
mbedtls_printf( " failed\n ! " mbedtls_printf( " failed\n ! mbedtls_ssl_set_client_transport_id() returned -0x%x\n\n",
"mbedtls_ssl_set_client_transport_id() returned -0x%x\n\n", -ret ); -ret );
goto exit; goto exit;
} }
} }

View File

@ -318,9 +318,8 @@ static int ctx_buffer_flush( ctx_buffer *buf )
{ {
int ret; int ret;
mbedtls_printf( " %05lu flush %s: %u bytes, %lu datagrams, " mbedtls_printf( " %05lu flush %s: %u bytes, %lu datagrams, last %ld ms\n",
"last %ld ms\n", ellapsed_time(), ellapsed_time(), buf->description, buf->len, buf->num_datagrams,
buf->description, buf->len, buf->num_datagrams,
ellapsed_time() - buf->packet_lifetime ); ellapsed_time() - buf->packet_lifetime );
ret = mbedtls_net_send( buf->ctx, buf->data, buf->len ); ret = mbedtls_net_send( buf->ctx, buf->data, buf->len );