mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-24 08:16:33 +01:00
Fixed bunch of X509_PARSE related defines / dependencies
This commit is contained in:
parent
30520d1776
commit
36713e8ed9
17 changed files with 107 additions and 98 deletions
|
|
@ -42,7 +42,7 @@
|
|||
#if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_ENTROPY_C) || \
|
||||
!defined(POLARSSL_SSL_TLS_C) || !defined(POLARSSL_SSL_CLI_C) || \
|
||||
!defined(POLARSSL_NET_C) || !defined(POLARSSL_RSA_C) || \
|
||||
!defined(POLARSSL_CTR_DRBG_C) || !defined(POLARSSL_X509_PARSE_C)
|
||||
!defined(POLARSSL_CTR_DRBG_C) || !defined(POLARSSL_X509_CRT_PARSE_C)
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
((void) argc);
|
||||
|
|
@ -51,7 +51,7 @@ int main( int argc, char *argv[] )
|
|||
printf("POLARSSL_BIGNUM_C and/or POLARSSL_ENTROPY_C and/or "
|
||||
"POLARSSL_SSL_TLS_C and/or POLARSSL_SSL_CLI_C and/or "
|
||||
"POLARSSL_NET_C and/or POLARSSL_RSA_C and/or "
|
||||
"POLARSSL_CTR_DRBG_C and/or POLARSSL_X509_PARSE_C "
|
||||
"POLARSSL_CTR_DRBG_C and/or POLARSSL_X509_CRT_PARSE_C "
|
||||
"not defined.\n");
|
||||
return( 0 );
|
||||
}
|
||||
|
|
@ -278,7 +278,7 @@ exit:
|
|||
}
|
||||
#endif
|
||||
|
||||
x509_free( &cacert );
|
||||
x509_crt_free( &cacert );
|
||||
net_close( server_fd );
|
||||
ssl_free( &ssl );
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ static void my_debug( void *ctx, int level, const char *str )
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(POLARSSL_X509_PARSE_C)
|
||||
#if defined(POLARSSL_X509_CRT_PARSE_C)
|
||||
/*
|
||||
* Enabled if debug_level > 1 in code below
|
||||
*/
|
||||
|
|
@ -150,9 +150,9 @@ static int my_verify( void *data, x509_cert *crt, int depth, int *flags )
|
|||
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* POLARSSL_X509_PARSE_C */
|
||||
#endif /* POLARSSL_X509_CRT_PARSE_C */
|
||||
|
||||
#if defined(POLARSSL_X509_PARSE_C)
|
||||
#if defined(POLARSSL_X509_CRT_PARSE_C)
|
||||
#if defined(POLARSSL_FS_IO)
|
||||
#define USAGE_IO \
|
||||
" ca_file=%%s The single file containing the top-level CA(s) you fully trust\n" \
|
||||
|
|
@ -168,7 +168,7 @@ static int my_verify( void *data, x509_cert *crt, int depth, int *flags )
|
|||
#endif /* POLARSSL_FS_IO */
|
||||
#else
|
||||
#define USAGE_IO ""
|
||||
#endif /* POLARSSL_X509_PARSE_C */
|
||||
#endif /* POLARSSL_X509_CRT_PARSE_C */
|
||||
|
||||
#if defined(POLARSSL_KEY_EXCHANGE_PSK_ENABLED)
|
||||
#define USAGE_PSK \
|
||||
|
|
@ -254,7 +254,7 @@ int main( int argc, char *argv[] )
|
|||
ctr_drbg_context ctr_drbg;
|
||||
ssl_context ssl;
|
||||
ssl_session saved_session;
|
||||
#if defined(POLARSSL_X509_PARSE_C)
|
||||
#if defined(POLARSSL_X509_CRT_PARSE_C)
|
||||
x509_cert cacert;
|
||||
x509_cert clicert;
|
||||
pk_context pkey;
|
||||
|
|
@ -268,7 +268,7 @@ int main( int argc, char *argv[] )
|
|||
server_fd = 0;
|
||||
memset( &ssl, 0, sizeof( ssl_context ) );
|
||||
memset( &saved_session, 0, sizeof( ssl_session ) );
|
||||
#if defined(POLARSSL_X509_PARSE_C)
|
||||
#if defined(POLARSSL_X509_CRT_PARSE_C)
|
||||
memset( &cacert, 0, sizeof( x509_cert ) );
|
||||
memset( &clicert, 0, sizeof( x509_cert ) );
|
||||
pk_init( &pkey );
|
||||
|
|
@ -565,7 +565,7 @@ int main( int argc, char *argv[] )
|
|||
|
||||
printf( " ok\n" );
|
||||
|
||||
#if defined(POLARSSL_X509_PARSE_C)
|
||||
#if defined(POLARSSL_X509_CRT_PARSE_C)
|
||||
/*
|
||||
* 1.1. Load the trusted CA
|
||||
*/
|
||||
|
|
@ -645,7 +645,7 @@ int main( int argc, char *argv[] )
|
|||
}
|
||||
|
||||
printf( " ok\n" );
|
||||
#endif /* POLARSSL_X509_PARSE_C */
|
||||
#endif /* POLARSSL_X509_CRT_PARSE_C */
|
||||
|
||||
/*
|
||||
* 2. Start the connection
|
||||
|
|
@ -677,7 +677,7 @@ int main( int argc, char *argv[] )
|
|||
|
||||
printf( " ok\n" );
|
||||
|
||||
#if defined(POLARSSL_X509_PARSE_C)
|
||||
#if defined(POLARSSL_X509_CRT_PARSE_C)
|
||||
if( opt.debug_level > 0 )
|
||||
ssl_set_verify( &ssl, my_verify, NULL );
|
||||
#endif
|
||||
|
|
@ -709,7 +709,7 @@ int main( int argc, char *argv[] )
|
|||
ssl_set_renegotiation( &ssl, opt.renegotiation );
|
||||
ssl_legacy_renegotiation( &ssl, opt.allow_legacy );
|
||||
|
||||
#if defined(POLARSSL_X509_PARSE_C)
|
||||
#if defined(POLARSSL_X509_CRT_PARSE_C)
|
||||
ssl_set_ca_chain( &ssl, &cacert, NULL, opt.server_name );
|
||||
ssl_set_own_cert( &ssl, &clicert, &pkey );
|
||||
#endif
|
||||
|
|
@ -760,7 +760,7 @@ int main( int argc, char *argv[] )
|
|||
printf( " ok\n" );
|
||||
}
|
||||
|
||||
#if defined(POLARSSL_X509_PARSE_C)
|
||||
#if defined(POLARSSL_X509_CRT_PARSE_C)
|
||||
/*
|
||||
* 5. Verify the server certificate
|
||||
*/
|
||||
|
|
@ -794,7 +794,7 @@ int main( int argc, char *argv[] )
|
|||
ssl_get_peer_cert( &ssl ) );
|
||||
printf( "%s\n", buf );
|
||||
}
|
||||
#endif /* POLARSSL_X509_PARSE_C */
|
||||
#endif /* POLARSSL_X509_CRT_PARSE_C */
|
||||
|
||||
/*
|
||||
* 6. Write the GET request
|
||||
|
|
@ -910,9 +910,9 @@ exit:
|
|||
|
||||
if( server_fd )
|
||||
net_close( server_fd );
|
||||
#if defined(POLARSSL_X509_PARSE_C)
|
||||
x509_free( &clicert );
|
||||
x509_free( &cacert );
|
||||
#if defined(POLARSSL_X509_CRT_PARSE_C)
|
||||
x509_crt_free( &clicert );
|
||||
x509_crt_free( &cacert );
|
||||
pk_free( &pkey );
|
||||
#endif
|
||||
ssl_session_free( &saved_session );
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@
|
|||
!defined(POLARSSL_ENTROPY_C) || !defined(POLARSSL_SSL_TLS_C) || \
|
||||
!defined(POLARSSL_SSL_SRV_C) || !defined(POLARSSL_NET_C) || \
|
||||
!defined(POLARSSL_RSA_C) || !defined(POLARSSL_CTR_DRBG_C) || \
|
||||
!defined(POLARSSL_X509_PARSE_C) || !defined(POLARSSL_TIMING_C)
|
||||
!defined(POLARSSL_X509_CRT_PARSE_C) || !defined(POLARSSL_TIMING_C)
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
((void) argc);
|
||||
|
|
@ -65,7 +65,7 @@ int main( int argc, char *argv[] )
|
|||
printf("POLARSSL_BIGNUM_C and/or POLARSSL_CERTS_C and/or POLARSSL_ENTROPY_C "
|
||||
"and/or POLARSSL_SSL_TLS_C and/or POLARSSL_SSL_SRV_C and/or "
|
||||
"POLARSSL_NET_C and/or POLARSSL_RSA_C and/or "
|
||||
"POLARSSL_CTR_DRBG_C and/or POLARSSL_X509_PARSE_C and/or "
|
||||
"POLARSSL_CTR_DRBG_C and/or POLARSSL_X509_CRT_PARSE_C and/or "
|
||||
"POLARSSL_TIMING_C not defined.\n");
|
||||
return( 0 );
|
||||
}
|
||||
|
|
@ -362,7 +362,7 @@ int main( int argc, char *argv[] )
|
|||
exit:
|
||||
|
||||
net_close( client_fd );
|
||||
x509_free( &srvcert );
|
||||
x509_crt_free( &srvcert );
|
||||
pk_free( &pkey );
|
||||
ssl_free( &ssl );
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@
|
|||
#if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_ENTROPY_C) || \
|
||||
!defined(POLARSSL_SSL_TLS_C) || !defined(POLARSSL_SSL_CLI_C) || \
|
||||
!defined(POLARSSL_NET_C) || !defined(POLARSSL_RSA_C) || \
|
||||
!defined(POLARSSL_CTR_DRBG_C) || !defined(POLARSSL_X509_PARSE_C)
|
||||
!defined(POLARSSL_CTR_DRBG_C) || !defined(POLARSSL_X509_CRT_PARSE_C)
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
((void) argc);
|
||||
|
|
@ -67,7 +67,7 @@ int main( int argc, char *argv[] )
|
|||
printf("POLARSSL_BIGNUM_C and/or POLARSSL_ENTROPY_C and/or "
|
||||
"POLARSSL_SSL_TLS_C and/or POLARSSL_SSL_CLI_C and/or "
|
||||
"POLARSSL_NET_C and/or POLARSSL_RSA_C and/or "
|
||||
"POLARSSL_CTR_DRBG_C and/or POLARSSL_X509_PARSE_C "
|
||||
"POLARSSL_CTR_DRBG_C and/or POLARSSL_X509_CRT_PARSE_C "
|
||||
"not defined.\n");
|
||||
return( 0 );
|
||||
}
|
||||
|
|
@ -790,8 +790,8 @@ exit:
|
|||
|
||||
if( server_fd )
|
||||
net_close( server_fd );
|
||||
x509_free( &clicert );
|
||||
x509_free( &cacert );
|
||||
x509_crt_free( &clicert );
|
||||
x509_crt_free( &cacert );
|
||||
pk_free( &pkey );
|
||||
ssl_free( &ssl );
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
!defined(POLARSSL_ENTROPY_C) || !defined(POLARSSL_SSL_TLS_C) || \
|
||||
!defined(POLARSSL_SSL_SRV_C) || !defined(POLARSSL_NET_C) || \
|
||||
!defined(POLARSSL_RSA_C) || !defined(POLARSSL_CTR_DRBG_C) || \
|
||||
!defined(POLARSSL_X509_PARSE_C)
|
||||
!defined(POLARSSL_X509_CRT_PARSE_C)
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
((void) argc);
|
||||
|
|
@ -62,7 +62,8 @@ int main( int argc, char *argv[] )
|
|||
printf("POLARSSL_BIGNUM_C and/or POLARSSL_CERTS_C and/or POLARSSL_ENTROPY_C "
|
||||
"and/or POLARSSL_SSL_TLS_C and/or POLARSSL_SSL_SRV_C and/or "
|
||||
"POLARSSL_NET_C and/or POLARSSL_RSA_C and/or "
|
||||
"POLARSSL_CTR_DRBG_C and/or POLARSSL_X509_PARSE_C not defined.\n");
|
||||
"POLARSSL_CTR_DRBG_C and/or POLARSSL_X509_CRT_PARSE_C "
|
||||
"not defined.\n");
|
||||
return( 0 );
|
||||
}
|
||||
#else
|
||||
|
|
@ -364,7 +365,7 @@ exit:
|
|||
#endif
|
||||
|
||||
net_close( client_fd );
|
||||
x509_free( &srvcert );
|
||||
x509_crt_free( &srvcert );
|
||||
pk_free( &pkey );
|
||||
ssl_free( &ssl );
|
||||
#if defined(POLARSSL_SSL_CACHE_C)
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ static void my_debug( void *ctx, int level, const char *str )
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(POLARSSL_X509_PARSE_C)
|
||||
#if defined(POLARSSL_X509_CRT_PARSE_C)
|
||||
#if defined(POLARSSL_FS_IO)
|
||||
#define USAGE_IO \
|
||||
" ca_file=%%s The single file containing the top-level CA(s) you fully trust\n" \
|
||||
|
|
@ -136,7 +136,7 @@ static void my_debug( void *ctx, int level, const char *str )
|
|||
#endif /* POLARSSL_FS_IO */
|
||||
#else
|
||||
#define USAGE_IO ""
|
||||
#endif /* POLARSSL_X509_PARSE_C */
|
||||
#endif /* POLARSSL_X509_CRT_PARSE_C */
|
||||
|
||||
#if defined(POLARSSL_KEY_EXCHANGE_PSK_ENABLED)
|
||||
#define USAGE_PSK \
|
||||
|
|
@ -212,7 +212,7 @@ int main( int argc, char *argv[] )
|
|||
entropy_context entropy;
|
||||
ctr_drbg_context ctr_drbg;
|
||||
ssl_context ssl;
|
||||
#if defined(POLARSSL_X509_PARSE_C)
|
||||
#if defined(POLARSSL_X509_CRT_PARSE_C)
|
||||
x509_cert cacert;
|
||||
x509_cert srvcert;
|
||||
pk_context pkey;
|
||||
|
|
@ -236,7 +236,7 @@ int main( int argc, char *argv[] )
|
|||
* Make sure memory references are valid.
|
||||
*/
|
||||
listen_fd = 0;
|
||||
#if defined(POLARSSL_X509_PARSE_C)
|
||||
#if defined(POLARSSL_X509_CRT_PARSE_C)
|
||||
memset( &cacert, 0, sizeof( x509_cert ) );
|
||||
memset( &srvcert, 0, sizeof( x509_cert ) );
|
||||
pk_init( &pkey );
|
||||
|
|
@ -516,7 +516,7 @@ int main( int argc, char *argv[] )
|
|||
|
||||
printf( " ok\n" );
|
||||
|
||||
#if defined(POLARSSL_X509_PARSE_C)
|
||||
#if defined(POLARSSL_X509_CRT_PARSE_C)
|
||||
/*
|
||||
* 1.1. Load the trusted CA
|
||||
*/
|
||||
|
|
@ -594,7 +594,7 @@ int main( int argc, char *argv[] )
|
|||
}
|
||||
|
||||
printf( " ok\n" );
|
||||
#endif /* POLARSSL_X509_PARSE_C */
|
||||
#endif /* POLARSSL_X509_CRT_PARSE_C */
|
||||
|
||||
/*
|
||||
* 2. Setup the listening TCP socket
|
||||
|
|
@ -647,7 +647,7 @@ int main( int argc, char *argv[] )
|
|||
ssl_set_renegotiation( &ssl, opt.renegotiation );
|
||||
ssl_legacy_renegotiation( &ssl, opt.allow_legacy );
|
||||
|
||||
#if defined(POLARSSL_X509_PARSE_C)
|
||||
#if defined(POLARSSL_X509_CRT_PARSE_C)
|
||||
ssl_set_ca_chain( &ssl, &cacert, NULL, NULL );
|
||||
ssl_set_own_cert( &ssl, &srvcert, &pkey );
|
||||
#endif
|
||||
|
|
@ -747,7 +747,7 @@ reset:
|
|||
printf( " ok\n [ Ciphersuite is %s ]\n",
|
||||
ssl_get_ciphersuite( &ssl ) );
|
||||
|
||||
#if defined(POLARSSL_X509_PARSE_C)
|
||||
#if defined(POLARSSL_X509_CRT_PARSE_C)
|
||||
/*
|
||||
* 5. Verify the server certificate
|
||||
*/
|
||||
|
|
@ -781,7 +781,7 @@ reset:
|
|||
ssl_get_peer_cert( &ssl ) );
|
||||
printf( "%s\n", buf );
|
||||
}
|
||||
#endif /* POLARSSL_X509_PARSE_C */
|
||||
#endif /* POLARSSL_X509_CRT_PARSE_C */
|
||||
|
||||
/*
|
||||
* 6. Read the HTTP Request
|
||||
|
|
@ -877,9 +877,9 @@ exit:
|
|||
#endif
|
||||
|
||||
net_close( client_fd );
|
||||
#if defined(POLARSSL_X509_PARSE_C)
|
||||
x509_free( &srvcert );
|
||||
x509_free( &cacert );
|
||||
#if defined(POLARSSL_X509_CRT_PARSE_C)
|
||||
x509_crt_free( &srvcert );
|
||||
x509_crt_free( &cacert );
|
||||
pk_free( &pkey );
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue