mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-26 03:25:30 +00:00
Fix ret code in cert_app.c
This commit is contained in:
parent
77d2de223c
commit
8ec767c042
|
@ -145,7 +145,8 @@ static int my_verify( void *data, mbedtls_x509_crt *crt, int depth, uint32_t *fl
|
||||||
|
|
||||||
int main( int argc, char *argv[] )
|
int main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 1;
|
||||||
|
int exit_code = MBEDTLS_EXIT_FAILURE;
|
||||||
mbedtls_net_context server_fd;
|
mbedtls_net_context server_fd;
|
||||||
unsigned char buf[1024];
|
unsigned char buf[1024];
|
||||||
mbedtls_entropy_context entropy;
|
mbedtls_entropy_context entropy;
|
||||||
|
@ -180,7 +181,6 @@ int main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
usage:
|
usage:
|
||||||
mbedtls_printf( USAGE );
|
mbedtls_printf( USAGE );
|
||||||
ret = 2;
|
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,19 +252,23 @@ int main( int argc, char *argv[] )
|
||||||
|
|
||||||
if( strlen( opt.ca_path ) )
|
if( strlen( opt.ca_path ) )
|
||||||
{
|
{
|
||||||
ret = mbedtls_x509_crt_parse_path( &cacert, opt.ca_path );
|
if( ( ret = mbedtls_x509_crt_parse_path( &cacert, opt.ca_path ) ) < 0 )
|
||||||
|
{
|
||||||
|
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_path returned -0x%x\n\n", -ret );
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
verify = 1;
|
verify = 1;
|
||||||
}
|
}
|
||||||
else if( strlen( opt.ca_file ) )
|
else if( strlen( opt.ca_file ) )
|
||||||
{
|
{
|
||||||
ret = mbedtls_x509_crt_parse_file( &cacert, opt.ca_file );
|
if( ( ret = mbedtls_x509_crt_parse_file( &cacert, opt.ca_file ) ) < 0 )
|
||||||
verify = 1;
|
{
|
||||||
|
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_file returned -0x%x\n\n", -ret );
|
||||||
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ret < 0 )
|
verify = 1;
|
||||||
{
|
|
||||||
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", -ret );
|
|
||||||
goto exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mbedtls_printf( " ok (%d skipped)\n", ret );
|
mbedtls_printf( " ok (%d skipped)\n", ret );
|
||||||
|
@ -332,8 +336,6 @@ int main( int argc, char *argv[] )
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 1.3 Verify the certificate
|
* 1.3 Verify the certificate
|
||||||
*/
|
*/
|
||||||
|
@ -470,6 +472,8 @@ ssl_exit:
|
||||||
else
|
else
|
||||||
goto usage;
|
goto usage;
|
||||||
|
|
||||||
|
exit_code = MBEDTLS_EXIT_SUCCESS;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
|
||||||
mbedtls_net_free( &server_fd );
|
mbedtls_net_free( &server_fd );
|
||||||
|
@ -485,10 +489,7 @@ exit:
|
||||||
fflush( stdout ); getchar();
|
fflush( stdout ); getchar();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( ret < 0 )
|
return( exit_code );
|
||||||
ret = 1;
|
|
||||||
|
|
||||||
return( ret );
|
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_SSL_TLS_C &&
|
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_SSL_TLS_C &&
|
||||||
MBEDTLS_SSL_CLI_C && MBEDTLS_NET_C && MBEDTLS_RSA_C &&
|
MBEDTLS_SSL_CLI_C && MBEDTLS_NET_C && MBEDTLS_RSA_C &&
|
||||||
|
|
Loading…
Reference in a new issue