diff --git a/src/internal.c b/src/internal.c index 9833d7979..e3bfa615a 100644 --- a/src/internal.c +++ b/src/internal.c @@ -6351,9 +6351,7 @@ static int DoAlert(WOLFSSL* ssl, byte* input, word32* inOutIdx, int* type, WOLFSSL_MSG(" close notify"); ssl->options.closeNotify = 1; } - if (!ssl->options.sentNotify) { - WOLFSSL_ERROR(*type); - } + WOLFSSL_ERROR(*type); if (ssl->keys.encryptionOn) { if (*inOutIdx + ssl->keys.padSz > totalSz) return BUFFER_E; @@ -7751,9 +7749,7 @@ startScr: while (ssl->buffers.clearOutputBuffer.length == 0) { if ( (ssl->error = ProcessReply(ssl)) < 0) { - if (!ssl->options.sentNotify) { - WOLFSSL_ERROR(ssl->error); - } + WOLFSSL_ERROR(ssl->error); if (ssl->error == ZERO_RETURN) { WOLFSSL_MSG("Zero return, no more data coming"); return 0; /* no more data coming */ diff --git a/src/ssl.c b/src/ssl.c index 5c61d6571..5025eab84 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -917,6 +917,7 @@ int wolfSSL_recv(WOLFSSL* ssl, void* data, int sz, int flags) /* SSL_SUCCESS on ok */ int wolfSSL_shutdown(WOLFSSL* ssl) { + byte tmp; WOLFSSL_ENTER("SSL_shutdown()"); if (ssl == NULL) @@ -937,23 +938,26 @@ int wolfSSL_shutdown(WOLFSSL* ssl) } ssl->options.sentNotify = 1; /* don't send close_notify twice */ WOLFSSL_LEAVE("SSL_shutdown()", ssl->error); - return 0; + + if (ssl->options.closeNotify) + return 1; + else + return 0; } /* call wolfSSL_shutdown again for bidirectional shudown */ if (ssl->options.sentNotify && !ssl->options.closeNotify) { - ssl->error = ReceiveData(ssl, 0, 0, 0); + ssl->error = wolfSSL_read(ssl, &tmp, 0); if (ssl->error < 0) { WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } + WOLFSSL_LEAVE("SSL_shutdown()", ssl->error); + ssl->error = SSL_ERROR_SYSCALL; /* simulate OpenSSL behavior */ + if(ssl->options.closeNotify) + return SSL_SUCCESS; } - - WOLFSSL_LEAVE("SSL_shutdown()", ssl->error); - - ssl->error = SSL_ERROR_SYSCALL; /* simulate OpenSSL behavior */ - - return SSL_SUCCESS; + return SSL_FATAL_ERROR; } diff --git a/wolfssl/test.h b/wolfssl/test.h index b500832eb..8720ff516 100644 --- a/wolfssl/test.h +++ b/wolfssl/test.h @@ -1800,7 +1800,7 @@ static INLINE const char* mymktemp(char *tempfn, int len, int num) static const char alphanum[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz"; RNG rng; - int out; + byte out; if (tempfn == NULL || len < 1 || num < 1 || len <= num) { printf("Bad input\n");