add fewerPacket/group messages to example client/server and disalbe client cert/key load
This commit is contained in:
parent
d665e16bd8
commit
702c1b044d
@ -113,6 +113,8 @@ static void Usage(void)
|
||||
printf("-m Match domain name in cert\n");
|
||||
printf("-N Use Non-blocking sockets\n");
|
||||
printf("-r Resume session\n");
|
||||
printf("-f Fewer packets/group messages\n");
|
||||
printf("-x Disable client cert/key loading\n");
|
||||
#ifdef SHOW_SIZES
|
||||
printf("-z Print structure sizes\n");
|
||||
#endif
|
||||
@ -152,6 +154,8 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
|
||||
int nonBlocking = 0;
|
||||
int resumeSession = 0;
|
||||
int trackMemory = 0;
|
||||
int useClientCert = 1;
|
||||
int fewerPackets = 0;
|
||||
char* cipherList = NULL;
|
||||
char* verifyCert = (char*)caCert;
|
||||
char* ourCert = (char*)cliCert;
|
||||
@ -172,7 +176,7 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
|
||||
(void)sslResume;
|
||||
(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) {
|
||||
case '?' :
|
||||
Usage();
|
||||
@ -204,6 +208,14 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
|
||||
matchName = 1;
|
||||
break;
|
||||
|
||||
case 'x' :
|
||||
useClientCert = 0;
|
||||
break;
|
||||
|
||||
case 'f' :
|
||||
fewerPackets = 1;
|
||||
break;
|
||||
|
||||
case 'h' :
|
||||
host = myoptarg;
|
||||
domain = myoptarg;
|
||||
@ -344,6 +356,9 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
|
||||
usePsk = 1;
|
||||
#endif
|
||||
|
||||
if (fewerPackets)
|
||||
CyaSSL_CTX_set_group_messages(ctx);
|
||||
|
||||
if (usePsk) {
|
||||
#ifndef NO_PSK
|
||||
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");
|
||||
}
|
||||
#endif
|
||||
useClientCert = 0;
|
||||
}
|
||||
|
||||
#ifdef OPENSSL_EXTRA
|
||||
@ -381,17 +397,18 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
|
||||
CyaSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, myVerify);
|
||||
#endif
|
||||
#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
|
||||
if (!usePsk){
|
||||
if (CyaSSL_CTX_use_certificate_file(ctx, ourCert, SSL_FILETYPE_PEM)
|
||||
!= SSL_SUCCESS)
|
||||
if (useClientCert){
|
||||
if (CyaSSL_CTX_use_certificate_chain_file(ctx, ourCert) != SSL_SUCCESS)
|
||||
err_sys("can't load client cert file, check file and run from"
|
||||
" CyaSSL home dir");
|
||||
|
||||
if (CyaSSL_CTX_use_PrivateKey_file(ctx, ourKey, SSL_FILETYPE_PEM)
|
||||
!= SSL_SUCCESS)
|
||||
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)
|
||||
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("-u Use UDP DTLS,"
|
||||
" 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");
|
||||
}
|
||||
|
||||
@ -131,9 +132,10 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
||||
int port = yasslPort;
|
||||
int usePsk = 0;
|
||||
int doDTLS = 0;
|
||||
int useNtruKey = 0;
|
||||
int nonBlocking = 0;
|
||||
int trackMemory = 0;
|
||||
int useNtruKey = 0;
|
||||
int nonBlocking = 0;
|
||||
int trackMemory = 0;
|
||||
int fewerPackets = 0;
|
||||
char* cipherList = NULL;
|
||||
char* verifyCert = (char*)cliCert;
|
||||
char* ourCert = (char*)svrCert;
|
||||
@ -150,7 +152,7 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
||||
#endif
|
||||
(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) {
|
||||
case '?' :
|
||||
Usage();
|
||||
@ -182,6 +184,10 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
||||
doDTLS = 1;
|
||||
break;
|
||||
|
||||
case 'f' :
|
||||
fewerPackets = 1;
|
||||
break;
|
||||
|
||||
case 'p' :
|
||||
port = atoi(myoptarg);
|
||||
#if !defined(NO_MAIN_DRIVER) || defined(USE_WINDOWS_API)
|
||||
@ -299,6 +305,9 @@ THREAD_RETURN CYASSL_THREAD server_test(void* args)
|
||||
usePsk = 1;
|
||||
#endif
|
||||
|
||||
if (fewerPackets)
|
||||
CyaSSL_CTX_set_group_messages(ctx);
|
||||
|
||||
#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
|
||||
if (!usePsk) {
|
||||
if (SSL_CTX_use_certificate_file(ctx, ourCert, SSL_FILETYPE_PEM)
|
||||
|
Loading…
Reference in New Issue
Block a user