Added wolfSSL_accept to TLS server examples, even though its not explicitly required.

pull/42/head
David Garske 2017-04-10 15:55:32 -07:00
parent 31cbabc7eb
commit 341c05f9f7
5 changed files with 48 additions and 5 deletions

View File

@ -151,6 +151,7 @@ int main()
char buff[256];
size_t len;
int shutdown = 0;
int ret;
/* declare wolfSSL objects */
WOLFSSL_CTX* ctx;
@ -247,6 +248,15 @@ int main()
/* Attach wolfSSL to the socket */
wolfSSL_set_fd(ssl, connd);
/* Establish TLS connection */
ret = wolfSSL_accept(ssl);
if (ret != SSL_SUCCESS) {
fprintf(stderr, "wolfSSL_accept error = %d\n",
wolfSSL_get_error(ssl, ret));
return -1;
}
printf("Client connected successfully\n");

View File

@ -53,6 +53,7 @@ int main()
char buff[256];
size_t len;
int shutdown = 0;
int ret;
/* declare wolfSSL objects */
WOLFSSL_CTX* ctx;
@ -149,8 +150,15 @@ int main()
/* Attach wolfSSL to the socket */
wolfSSL_set_fd(ssl, connd);
printf("Client connected successfully\n");
/* Establish TLS connection */
ret = wolfSSL_accept(ssl);
if (ret != SSL_SUCCESS) {
fprintf(stderr, "wolfSSL_accept error = %d\n",
wolfSSL_get_error(ssl, ret));
return -1;
}
printf("Client connected successfully\n");
/* Read the client data into our buff array */
@ -170,7 +178,6 @@ int main()
}
/* Write our reply into buff */
memset(buff, 0, sizeof(buff));
memcpy(buff, "I hear ya fa shizzle!\n", sizeof(buff));

View File

@ -52,6 +52,7 @@ int main()
char buff[256];
size_t len;
int shutdown = 0;
int ret;
/* declare wolfSSL objects */
WOLFSSL_CTX* ctx;
@ -152,8 +153,15 @@ int main()
/* Attach wolfSSL to the socket */
wolfSSL_set_fd(ssl, connd);
printf("Client connected successfully\n");
/* Establish TLS connection */
ret = wolfSSL_accept(ssl);
if (ret != SSL_SUCCESS) {
fprintf(stderr, "wolfSSL_accept error = %d\n",
wolfSSL_get_error(ssl, ret));
return -1;
}
printf("Client connected successfully\n");
/* Read the client data into our buff array */

View File

@ -64,7 +64,7 @@ void* ClientHandler(void* args)
WOLFSSL* ssl;
char buff[256];
size_t len;
int ret;
/* Create a WOLFSSL object */
@ -77,8 +77,16 @@ void* ClientHandler(void* args)
/* Attach wolfSSL to the socket */
wolfSSL_set_fd(ssl, pkg->connd);
printf("Client %d connected successfully\n", pkg->num);
/* Establish TLS connection */
ret = wolfSSL_accept(ssl);
if (ret != SSL_SUCCESS) {
fprintf(stderr, "wolfSSL_accept error = %d\n",
wolfSSL_get_error(ssl, ret));
pkg->open = 1;
pthread_exit(NULL);
}
printf("Client %d connected successfully\n", pkg->num);
/* Read the client data into our buff array */

View File

@ -51,6 +51,7 @@ int main()
char buff[256];
size_t len;
int shutdown = 0;
int ret;
/* declare wolfSSL objects */
WOLFSSL_CTX* ctx;
@ -141,6 +142,15 @@ int main()
/* Attach wolfSSL to the socket */
wolfSSL_set_fd(ssl, connd);
/* Establish TLS connection */
ret = wolfSSL_accept(ssl);
if (ret != SSL_SUCCESS) {
fprintf(stderr, "wolfSSL_accept error = %d\n",
wolfSSL_get_error(ssl, ret));
return -1;
}
printf("Client connected successfully\n");