forked from wolfSSL/wolfssl
add fewerPacket/group messages to example client/server and disalbe client cert/key load
This commit is contained in:
@ -113,6 +113,8 @@ static void Usage(void)
|
|||||||
printf("-m Match domain name in cert\n");
|
printf("-m Match domain name in cert\n");
|
||||||
printf("-N Use Non-blocking sockets\n");
|
printf("-N Use Non-blocking sockets\n");
|
||||||
printf("-r Resume session\n");
|
printf("-r Resume session\n");
|
||||||
|
printf("-f Fewer packets/group messages\n");
|
||||||
|
printf("-x Disable client cert/key loading\n");
|
||||||
#ifdef SHOW_SIZES
|
#ifdef SHOW_SIZES
|
||||||
printf("-z Print structure sizes\n");
|
printf("-z Print structure sizes\n");
|
||||||
#endif
|
#endif
|
||||||
@ -152,6 +154,8 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
|
|||||||
int nonBlocking = 0;
|
int nonBlocking = 0;
|
||||||
int resumeSession = 0;
|
int resumeSession = 0;
|
||||||
int trackMemory = 0;
|
int trackMemory = 0;
|
||||||
|
int useClientCert = 1;
|
||||||
|
int fewerPackets = 0;
|
||||||
char* cipherList = NULL;
|
char* cipherList = NULL;
|
||||||
char* verifyCert = (char*)caCert;
|
char* verifyCert = (char*)caCert;
|
||||||
char* ourCert = (char*)cliCert;
|
char* ourCert = (char*)cliCert;
|
||||||
@ -172,7 +176,7 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
|
|||||||
(void)sslResume;
|
(void)sslResume;
|
||||||
(void)trackMemory;
|
(void)trackMemory;
|
||||||
|
|
||||||
while ((ch = mygetopt(argc, argv, "?gdusmNrth:p:v:l:A:c:k:b:z")) != -1) {
|
while ((ch = mygetopt(argc, argv, "?gdusmNrtfxh:p:v:l:A:c:k:b:z")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case '?' :
|
case '?' :
|
||||||
Usage();
|
Usage();
|
||||||
@ -204,6 +208,14 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
|
|||||||
matchName = 1;
|
matchName = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'x' :
|
||||||
|
useClientCert = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'f' :
|
||||||
|
fewerPackets = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'h' :
|
case 'h' :
|
||||||
host = myoptarg;
|
host = myoptarg;
|
||||||
domain = myoptarg;
|
domain = myoptarg;
|
||||||
@ -344,6 +356,9 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
|
|||||||
usePsk = 1;
|
usePsk = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (fewerPackets)
|
||||||
|
CyaSSL_CTX_set_group_messages(ctx);
|
||||||
|
|
||||||
if (usePsk) {
|
if (usePsk) {
|
||||||
#ifndef NO_PSK
|
#ifndef NO_PSK
|
||||||
CyaSSL_CTX_set_psk_client_callback(ctx, my_psk_client_cb);
|
CyaSSL_CTX_set_psk_client_callback(ctx, my_psk_client_cb);
|
||||||
@ -358,6 +373,7 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
|
|||||||
err_sys("client can't set cipher list 2");
|
err_sys("client can't set cipher list 2");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
useClientCert = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OPENSSL_EXTRA
|
#ifdef OPENSSL_EXTRA
|
||||||
@ -381,9 +397,8 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
|
|||||||
CyaSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, myVerify);
|
CyaSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, myVerify);
|
||||||
#endif
|
#endif
|
||||||
#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
|
#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
|
||||||
if (!usePsk){
|
if (useClientCert){
|
||||||
if (CyaSSL_CTX_use_certificate_file(ctx, ourCert, SSL_FILETYPE_PEM)
|
if (CyaSSL_CTX_use_certificate_chain_file(ctx, ourCert) != SSL_SUCCESS)
|
||||||
!= SSL_SUCCESS)
|
|
||||||
err_sys("can't load client cert file, check file and run from"
|
err_sys("can't load client cert file, check file and run from"
|
||||||
" CyaSSL home dir");
|
" CyaSSL home dir");
|
||||||
|
|
||||||
@ -391,7 +406,9 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
|
|||||||
!= SSL_SUCCESS)
|
!= SSL_SUCCESS)
|
||||||
err_sys("can't load client private key file, check file and run "
|
err_sys("can't load client private key file, check file and run "
|
||||||
"from CyaSSL home dir");
|
"from CyaSSL home dir");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!usePsk) {
|
||||||
if (CyaSSL_CTX_load_verify_locations(ctx, verifyCert, 0) != SSL_SUCCESS)
|
if (CyaSSL_CTX_load_verify_locations(ctx, verifyCert, 0) != SSL_SUCCESS)
|
||||||
err_sys("can't load ca file, Please run from CyaSSL home dir");
|
err_sys("can't load ca file, Please run from CyaSSL home dir");
|
||||||
}
|
}
|
||||||
|
@ -108,6 +108,7 @@ static void Usage(void)
|
|||||||
printf("-t Track CyaSSL memory use\n");
|
printf("-t Track CyaSSL memory use\n");
|
||||||
printf("-u Use UDP DTLS,"
|
printf("-u Use UDP DTLS,"
|
||||||
" add -v 2 for DTLSv1 (default), -v 3 for DTLSv1.2\n");
|
" add -v 2 for DTLSv1 (default), -v 3 for DTLSv1.2\n");
|
||||||
|
printf("-f Fewer packets/group messages\n");
|
||||||
printf("-N Use Non-blocking sockets\n");
|
printf("-N Use Non-blocking sockets\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,6 +135,7 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
|||||||
int useNtruKey = 0;
|
int useNtruKey = 0;
|
||||||
int nonBlocking = 0;
|
int nonBlocking = 0;
|
||||||
int trackMemory = 0;
|
int trackMemory = 0;
|
||||||
|
int fewerPackets = 0;
|
||||||
char* cipherList = NULL;
|
char* cipherList = NULL;
|
||||||
char* verifyCert = (char*)cliCert;
|
char* verifyCert = (char*)cliCert;
|
||||||
char* ourCert = (char*)svrCert;
|
char* ourCert = (char*)svrCert;
|
||||||
@ -150,7 +152,7 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
|||||||
#endif
|
#endif
|
||||||
(void)trackMemory;
|
(void)trackMemory;
|
||||||
|
|
||||||
while ((ch = mygetopt(argc, argv, "?dbstnNup:v:l:A:c:k:")) != -1) {
|
while ((ch = mygetopt(argc, argv, "?dbstnNufp:v:l:A:c:k:")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case '?' :
|
case '?' :
|
||||||
Usage();
|
Usage();
|
||||||
@ -182,6 +184,10 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
|||||||
doDTLS = 1;
|
doDTLS = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'f' :
|
||||||
|
fewerPackets = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'p' :
|
case 'p' :
|
||||||
port = atoi(myoptarg);
|
port = atoi(myoptarg);
|
||||||
#if !defined(NO_MAIN_DRIVER) || defined(USE_WINDOWS_API)
|
#if !defined(NO_MAIN_DRIVER) || defined(USE_WINDOWS_API)
|
||||||
@ -299,6 +305,9 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
|||||||
usePsk = 1;
|
usePsk = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (fewerPackets)
|
||||||
|
CyaSSL_CTX_set_group_messages(ctx);
|
||||||
|
|
||||||
#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
|
#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
|
||||||
if (!usePsk) {
|
if (!usePsk) {
|
||||||
if (SSL_CTX_use_certificate_file(ctx, ourCert, SSL_FILETYPE_PEM)
|
if (SSL_CTX_use_certificate_file(ctx, ourCert, SSL_FILETYPE_PEM)
|
||||||
|
Reference in New Issue
Block a user