mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-01 03:34:39 +02:00
Implement non-blocking SCR on server side
This commit is contained in:
@@ -2456,8 +2456,44 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||
defined(HAVE_SERVER_RENEGOTIATION_INFO)
|
||||
if (scr && forceScr) {
|
||||
if (nonBlocking) {
|
||||
printf("not doing secure renegotiation on example with"
|
||||
" nonblocking yet\n");
|
||||
if ((ret = wolfSSL_Rehandshake(ssl)) != WOLFSSL_SUCCESS) {
|
||||
err = wolfSSL_get_error(ssl, 0);
|
||||
if (err == WOLFSSL_ERROR_WANT_READ ||
|
||||
err == WOLFSSL_ERROR_WANT_WRITE) {
|
||||
do {
|
||||
if (err == APP_DATA_READY) {
|
||||
if ((ret = wolfSSL_read(ssl, input, sizeof(input)-1)) < 0) {
|
||||
err_sys("APP DATA should be present but error returned");
|
||||
}
|
||||
printf("Received message: %s\n", input);
|
||||
}
|
||||
err = 0;
|
||||
if ((ret = wolfSSL_accept(ssl)) != WOLFSSL_SUCCESS) {
|
||||
err = wolfSSL_get_error(ssl, ret);
|
||||
}
|
||||
} while (ret != WOLFSSL_SUCCESS &&
|
||||
(err == WOLFSSL_ERROR_WANT_READ ||
|
||||
err == WOLFSSL_ERROR_WANT_WRITE ||
|
||||
err == APP_DATA_READY));
|
||||
|
||||
if (ret != WOLFSSL_SUCCESS) {
|
||||
err = wolfSSL_get_error(ssl, 0);
|
||||
printf("wolfSSL_Rehandshake error %d, %s\n", err,
|
||||
wolfSSL_ERR_error_string(err, buffer));
|
||||
wolfSSL_free(ssl); ssl = NULL;
|
||||
wolfSSL_CTX_free(ctx); ctx = NULL;
|
||||
err_sys("non-blocking wolfSSL_Rehandshake failed");
|
||||
}
|
||||
printf("NON-BLOCKING RENEGOTIATION SUCCESSFUL\n");
|
||||
}
|
||||
else {
|
||||
printf("wolfSSL_Rehandshake error %d, %s\n", err,
|
||||
wolfSSL_ERR_error_string(err, buffer));
|
||||
wolfSSL_free(ssl); ssl = NULL;
|
||||
wolfSSL_CTX_free(ctx); ctx = NULL;
|
||||
err_sys("non-blocking wolfSSL_Rehandshake failed");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ((ret = wolfSSL_Rehandshake(ssl)) != WOLFSSL_SUCCESS) {
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
|
Reference in New Issue
Block a user