Merge remote-tracking branch 'origin/pr/2260' into development
* origin/pr/2260: Update crypto submodule Remove heading spaces in tests/data_files/Makefile Re-generate library/certs.c from script Add new line at the end of test-ca2.key.enc Use strict syntax to annotate origin of test data in certs.c Add run to all.sh exercising !MBEDTLS_PEM_PARSE_C + !MBEDTLS_FS_IO Allow DHM self test to run without MBEDTLS_PEM_PARSE_C ssl-opt.sh: Auto-skip tests that use files if MBEDTLS_FS_IO unset Document origin of hardcoded certificates in library/certs.c Adapt ChangeLog Rename server1.der to server1.crt.der Add DER encoded files to git tree Add build instructions to generate DER versions of CRTs and keys Document "none" value for ca_path/ca_file in ssl_client2/ssl_server2 ssl_server2: Skip CA setup if `ca_path` or `ca_file` argument "none" ssl_client2: Skip CA setup if `ca_path` or `ca_file` argument "none" Correct white spaces in ssl_server2 and ssl_client2 Adapt ssl_client2 to parse DER encoded test CRTs if PEM is disabled Adapt ssl_server2 to parse DER encoded test CRTs if PEM is disabled
This commit is contained in:
commit
e1b02df515
28 changed files with 2055 additions and 443 deletions
programs/ssl
|
@ -150,8 +150,10 @@ int main( void )
|
|||
#define USAGE_IO \
|
||||
" ca_file=%%s The single file containing the top-level CA(s) you fully trust\n" \
|
||||
" default: \"\" (pre-loaded)\n" \
|
||||
" use \"none\" to skip loading any top-level CAs.\n" \
|
||||
" ca_path=%%s The path containing the top-level CA(s) you fully trust\n" \
|
||||
" default: \"\" (pre-loaded) (overrides ca_file)\n" \
|
||||
" use \"none\" to skip loading any top-level CAs.\n" \
|
||||
" crt_file=%%s Your own cert and chain (in bottom to top order, top may be omitted)\n" \
|
||||
" default: \"\" (pre-loaded)\n" \
|
||||
" key_file=%%s default: \"\" (pre-loaded)\n"
|
||||
|
@ -1681,20 +1683,22 @@ int main( int argc, char *argv[] )
|
|||
mbedtls_printf( " . Loading the CA root certificate ..." );
|
||||
fflush( stdout );
|
||||
|
||||
if( strcmp( opt.ca_path, "none" ) == 0 ||
|
||||
strcmp( opt.ca_file, "none" ) == 0 )
|
||||
{
|
||||
ret = 0;
|
||||
}
|
||||
else
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
if( strlen( opt.ca_path ) )
|
||||
if( strcmp( opt.ca_path, "none" ) == 0 )
|
||||
ret = 0;
|
||||
else
|
||||
ret = mbedtls_x509_crt_parse_path( &cacert, opt.ca_path );
|
||||
ret = mbedtls_x509_crt_parse_path( &cacert, opt.ca_path );
|
||||
else if( strlen( opt.ca_file ) )
|
||||
if( strcmp( opt.ca_file, "none" ) == 0 )
|
||||
ret = 0;
|
||||
else
|
||||
ret = mbedtls_x509_crt_parse_file( &cacert, opt.ca_file );
|
||||
ret = mbedtls_x509_crt_parse_file( &cacert, opt.ca_file );
|
||||
else
|
||||
#endif
|
||||
#if defined(MBEDTLS_CERTS_C)
|
||||
{
|
||||
#if defined(MBEDTLS_PEM_PARSE_C)
|
||||
for( i = 0; mbedtls_test_cas[i] != NULL; i++ )
|
||||
{
|
||||
ret = mbedtls_x509_crt_parse( &cacert,
|
||||
|
@ -1703,12 +1707,23 @@ int main( int argc, char *argv[] )
|
|||
if( ret != 0 )
|
||||
break;
|
||||
}
|
||||
if( ret == 0 )
|
||||
#endif /* MBEDTLS_PEM_PARSE_C */
|
||||
for( i = 0; mbedtls_test_cas_der[i] != NULL; i++ )
|
||||
{
|
||||
ret = mbedtls_x509_crt_parse_der( &cacert,
|
||||
(const unsigned char *) mbedtls_test_cas_der[i],
|
||||
mbedtls_test_cas_der_len[i] );
|
||||
if( ret != 0 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
ret = 1;
|
||||
mbedtls_printf( "MBEDTLS_CERTS_C not defined." );
|
||||
}
|
||||
#endif
|
||||
#endif /* MBEDTLS_CERTS_C */
|
||||
if( ret < 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n",
|
||||
|
@ -1726,12 +1741,12 @@ int main( int argc, char *argv[] )
|
|||
mbedtls_printf( " . Loading the client cert. and key..." );
|
||||
fflush( stdout );
|
||||
|
||||
if( strcmp( opt.crt_file, "none" ) == 0 )
|
||||
ret = 0;
|
||||
else
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
if( strlen( opt.crt_file ) )
|
||||
if( strcmp( opt.crt_file, "none" ) == 0 )
|
||||
ret = 0;
|
||||
else
|
||||
ret = mbedtls_x509_crt_parse_file( &clicert, opt.crt_file );
|
||||
ret = mbedtls_x509_crt_parse_file( &clicert, opt.crt_file );
|
||||
else
|
||||
#endif
|
||||
#if defined(MBEDTLS_CERTS_C)
|
||||
|
@ -1741,7 +1756,7 @@ int main( int argc, char *argv[] )
|
|||
#else
|
||||
{
|
||||
ret = 1;
|
||||
mbedtls_printf("MBEDTLS_CERTS_C not defined.");
|
||||
mbedtls_printf( "MBEDTLS_CERTS_C not defined." );
|
||||
}
|
||||
#endif
|
||||
if( ret != 0 )
|
||||
|
@ -1751,12 +1766,12 @@ int main( int argc, char *argv[] )
|
|||
goto exit;
|
||||
}
|
||||
|
||||
if( strcmp( opt.key_file, "none" ) == 0 )
|
||||
ret = 0;
|
||||
else
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
if( strlen( opt.key_file ) )
|
||||
if( strcmp( opt.key_file, "none" ) == 0 )
|
||||
ret = 0;
|
||||
else
|
||||
ret = mbedtls_pk_parse_keyfile( &pkey, opt.key_file, "" );
|
||||
ret = mbedtls_pk_parse_keyfile( &pkey, opt.key_file, "" );
|
||||
else
|
||||
#endif
|
||||
#if defined(MBEDTLS_CERTS_C)
|
||||
|
@ -1766,7 +1781,7 @@ int main( int argc, char *argv[] )
|
|||
#else
|
||||
{
|
||||
ret = 1;
|
||||
mbedtls_printf("MBEDTLS_CERTS_C not defined.");
|
||||
mbedtls_printf( "MBEDTLS_CERTS_C not defined." );
|
||||
}
|
||||
#endif
|
||||
if( ret != 0 )
|
||||
|
|
|
@ -202,8 +202,10 @@ int main( void )
|
|||
#define USAGE_IO \
|
||||
" ca_file=%%s The single file containing the top-level CA(s) you fully trust\n" \
|
||||
" default: \"\" (pre-loaded)\n" \
|
||||
" use \"none\" to skip loading any top-level CAs.\n" \
|
||||
" ca_path=%%s The path containing the top-level CA(s) you fully trust\n" \
|
||||
" default: \"\" (pre-loaded) (overrides ca_file)\n" \
|
||||
" use \"none\" to skip loading any top-level CAs.\n" \
|
||||
" crt_file=%%s Your own cert and chain (in bottom to top order, top may be omitted)\n" \
|
||||
" default: see note after key_file2\n" \
|
||||
" key_file=%%s default: see note after key_file2\n" \
|
||||
|
@ -2464,20 +2466,22 @@ int main( int argc, char *argv[] )
|
|||
mbedtls_printf( " . Loading the CA root certificate ..." );
|
||||
fflush( stdout );
|
||||
|
||||
if( strcmp( opt.ca_path, "none" ) == 0 ||
|
||||
strcmp( opt.ca_file, "none" ) == 0 )
|
||||
{
|
||||
ret = 0;
|
||||
}
|
||||
else
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
if( strlen( opt.ca_path ) )
|
||||
if( strcmp( opt.ca_path, "none" ) == 0 )
|
||||
ret = 0;
|
||||
else
|
||||
ret = mbedtls_x509_crt_parse_path( &cacert, opt.ca_path );
|
||||
ret = mbedtls_x509_crt_parse_path( &cacert, opt.ca_path );
|
||||
else if( strlen( opt.ca_file ) )
|
||||
if( strcmp( opt.ca_file, "none" ) == 0 )
|
||||
ret = 0;
|
||||
else
|
||||
ret = mbedtls_x509_crt_parse_file( &cacert, opt.ca_file );
|
||||
ret = mbedtls_x509_crt_parse_file( &cacert, opt.ca_file );
|
||||
else
|
||||
#endif
|
||||
#if defined(MBEDTLS_CERTS_C)
|
||||
{
|
||||
#if defined(MBEDTLS_PEM_PARSE_C)
|
||||
for( i = 0; mbedtls_test_cas[i] != NULL; i++ )
|
||||
{
|
||||
ret = mbedtls_x509_crt_parse( &cacert,
|
||||
|
@ -2486,12 +2490,23 @@ int main( int argc, char *argv[] )
|
|||
if( ret != 0 )
|
||||
break;
|
||||
}
|
||||
if( ret == 0 )
|
||||
#endif /* MBEDTLS_PEM_PARSE_C */
|
||||
for( i = 0; mbedtls_test_cas_der[i] != NULL; i++ )
|
||||
{
|
||||
ret = mbedtls_x509_crt_parse_der( &cacert,
|
||||
(const unsigned char *) mbedtls_test_cas_der[i],
|
||||
mbedtls_test_cas_der_len[i] );
|
||||
if( ret != 0 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
ret = 1;
|
||||
mbedtls_printf("MBEDTLS_CERTS_C not defined.");
|
||||
mbedtls_printf( "MBEDTLS_CERTS_C not defined." );
|
||||
}
|
||||
#endif
|
||||
#endif /* MBEDTLS_CERTS_C */
|
||||
if( ret < 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", -ret );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue