mirror of https://github.com/wolfSSL/wolfssl
Merge pull request #2802 from embhorn/zd9764
Fix for bidirectional shutdown
This commit is contained in:
commit
65cf5a0d46
|
@ -783,8 +783,16 @@ static int SMTP_Shutdown(WOLFSSL* ssl, int wc_shutdown)
|
||||||
printf("%s\n", tmpBuf);
|
printf("%s\n", tmpBuf);
|
||||||
|
|
||||||
ret = wolfSSL_shutdown(ssl);
|
ret = wolfSSL_shutdown(ssl);
|
||||||
if (wc_shutdown && ret == WOLFSSL_SHUTDOWN_NOT_DONE)
|
if (wc_shutdown && ret == WOLFSSL_SHUTDOWN_NOT_DONE) {
|
||||||
wolfSSL_shutdown(ssl); /* bidirectional shutdown */
|
if (tcp_select(wolfSSL_get_fd(ssl), DEFAULT_TIMEOUT_SEC) ==
|
||||||
|
TEST_RECV_READY) {
|
||||||
|
ret = wolfSSL_shutdown(ssl); /* bidirectional shutdown */
|
||||||
|
if (ret == WOLFSSL_SUCCESS)
|
||||||
|
printf("Bidirectional shutdown complete\n");
|
||||||
|
}
|
||||||
|
if (ret != WOLFSSL_SUCCESS)
|
||||||
|
printf("Bidirectional shutdown failed\n");
|
||||||
|
}
|
||||||
|
|
||||||
return WOLFSSL_SUCCESS;
|
return WOLFSSL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -3110,8 +3118,15 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
||||||
|
|
||||||
if (dtlsUDP == 0) { /* don't send alert after "break" command */
|
if (dtlsUDP == 0) { /* don't send alert after "break" command */
|
||||||
ret = wolfSSL_shutdown(ssl);
|
ret = wolfSSL_shutdown(ssl);
|
||||||
if (wc_shutdown && ret == WOLFSSL_SHUTDOWN_NOT_DONE)
|
if (wc_shutdown && ret == WOLFSSL_SHUTDOWN_NOT_DONE) {
|
||||||
wolfSSL_shutdown(ssl); /* bidirectional shutdown */
|
if (tcp_select(sockfd, DEFAULT_TIMEOUT_SEC) == TEST_RECV_READY) {
|
||||||
|
ret = wolfSSL_shutdown(ssl); /* bidirectional shutdown */
|
||||||
|
if (ret == WOLFSSL_SUCCESS)
|
||||||
|
printf("Bidirectional shutdown complete\n");
|
||||||
|
}
|
||||||
|
if (ret != WOLFSSL_SUCCESS)
|
||||||
|
printf("Bidirectional shutdown failed\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#if defined(ATOMIC_USER) && !defined(WOLFSSL_AEAD_ONLY)
|
#if defined(ATOMIC_USER) && !defined(WOLFSSL_AEAD_ONLY)
|
||||||
if (atomicUser)
|
if (atomicUser)
|
||||||
|
|
|
@ -51,6 +51,8 @@
|
||||||
static int devId = INVALID_DEVID;
|
static int devId = INVALID_DEVID;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define DEFAULT_TIMEOUT_SEC 2
|
||||||
|
|
||||||
/* Note on using port 0: if the server uses port 0 to bind an ephemeral port
|
/* Note on using port 0: if the server uses port 0 to bind an ephemeral port
|
||||||
* number and is using the ready file for scripted testing, the code in
|
* number and is using the ready file for scripted testing, the code in
|
||||||
* test.h will write the actual port number into the ready file for use
|
* test.h will write the actual port number into the ready file for use
|
||||||
|
@ -2427,9 +2429,13 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
||||||
|
|
||||||
if (dtlsUDP == 0) {
|
if (dtlsUDP == 0) {
|
||||||
ret = SSL_shutdown(ssl);
|
ret = SSL_shutdown(ssl);
|
||||||
if (wc_shutdown && ret == WOLFSSL_SHUTDOWN_NOT_DONE)
|
if (wc_shutdown && ret == WOLFSSL_SHUTDOWN_NOT_DONE) {
|
||||||
SSL_shutdown(ssl); /* bidirectional shutdown */
|
ret = SSL_shutdown(ssl); /* bidirectional shutdown */
|
||||||
|
if (ret == WOLFSSL_SUCCESS)
|
||||||
|
printf("Bidirectional shutdown complete\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* display collected statistics */
|
/* display collected statistics */
|
||||||
#ifdef WOLFSSL_STATIC_MEMORY
|
#ifdef WOLFSSL_STATIC_MEMORY
|
||||||
if (wolfSSL_is_static_memory(ssl, &ssl_stats) != 1)
|
if (wolfSSL_is_static_memory(ssl, &ssl_stats) != 1)
|
||||||
|
|
17
src/ssl.c
17
src/ssl.c
|
@ -2973,7 +2973,6 @@ WOLFSSL_ABI
|
||||||
int wolfSSL_shutdown(WOLFSSL* ssl)
|
int wolfSSL_shutdown(WOLFSSL* ssl)
|
||||||
{
|
{
|
||||||
int ret = WOLFSSL_FATAL_ERROR;
|
int ret = WOLFSSL_FATAL_ERROR;
|
||||||
byte tmp;
|
|
||||||
WOLFSSL_ENTER("SSL_shutdown()");
|
WOLFSSL_ENTER("SSL_shutdown()");
|
||||||
|
|
||||||
if (ssl == NULL)
|
if (ssl == NULL)
|
||||||
|
@ -3012,16 +3011,16 @@ int wolfSSL_shutdown(WOLFSSL* ssl)
|
||||||
|
|
||||||
/* call wolfSSL_shutdown again for bidirectional shutdown */
|
/* call wolfSSL_shutdown again for bidirectional shutdown */
|
||||||
if (ssl->options.sentNotify && !ssl->options.closeNotify) {
|
if (ssl->options.sentNotify && !ssl->options.closeNotify) {
|
||||||
ret = wolfSSL_read(ssl, &tmp, 0);
|
ret = ProcessReply(ssl);
|
||||||
if (ret < 0) {
|
if (ret == ZERO_RETURN) {
|
||||||
|
/* simulate OpenSSL behavior */
|
||||||
|
ssl->error = WOLFSSL_ERROR_SYSCALL;
|
||||||
|
ret = WOLFSSL_SUCCESS;
|
||||||
|
} else if (ssl->error == WOLFSSL_ERROR_NONE) {
|
||||||
|
ret = WOLFSSL_SHUTDOWN_NOT_DONE;
|
||||||
|
} else {
|
||||||
WOLFSSL_ERROR(ssl->error);
|
WOLFSSL_ERROR(ssl->error);
|
||||||
ret = WOLFSSL_FATAL_ERROR;
|
ret = WOLFSSL_FATAL_ERROR;
|
||||||
} else if (ssl->options.closeNotify) {
|
|
||||||
ssl->error = WOLFSSL_ERROR_SYSCALL; /* simulate OpenSSL behavior */
|
|
||||||
ret = WOLFSSL_SUCCESS;
|
|
||||||
} else if ((ssl->error == WOLFSSL_ERROR_NONE) &&
|
|
||||||
(ret < WOLFSSL_SUCCESS)) {
|
|
||||||
ret = WOLFSSL_SHUTDOWN_NOT_DONE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2200,3 +2200,9 @@
|
||||||
-v 3
|
-v 3
|
||||||
-l ECDHE-RSA-AES128-SHA256
|
-l ECDHE-RSA-AES128-SHA256
|
||||||
-U
|
-U
|
||||||
|
|
||||||
|
# server with bidirectional shutdown
|
||||||
|
-w
|
||||||
|
|
||||||
|
# client with bidirectional shutdown
|
||||||
|
-w
|
||||||
|
|
Loading…
Reference in New Issue