diff --git a/src/internal.c b/src/internal.c index 73fbc6626..ce8f2b909 100644 --- a/src/internal.c +++ b/src/internal.c @@ -16332,6 +16332,11 @@ static int DoHandShakeMsgType(WOLFSSL* ssl, byte* input, word32* inOutIdx, } #if defined(WOLFSSL_ASYNC_CRYPT) || defined(WOLFSSL_NONBLOCK_OCSP) + /* make sure async error is cleared */ + if (ret == 0 && (ssl->error == WC_PENDING_E || ssl->error == OCSP_WANT_READ)) { + ssl->error = 0; + } + /* if async, offset index so this msg will be processed again */ if ((ret == WC_PENDING_E || ret == OCSP_WANT_READ) && *inOutIdx > 0) { *inOutIdx -= HANDSHAKE_HEADER_SZ; @@ -16340,11 +16345,10 @@ static int DoHandShakeMsgType(WOLFSSL* ssl, byte* input, word32* inOutIdx, *inOutIdx -= DTLS_HANDSHAKE_EXTRA; } #endif - } - /* make sure async error is cleared */ - if (ret == 0 && (ssl->error == WC_PENDING_E || ssl->error == OCSP_WANT_READ)) { - ssl->error = 0; + /* set the async error so the re-run will work and won't send alert */ + ssl->error = ret; + ret = 0; } #endif /* WOLFSSL_ASYNC_CRYPT || WOLFSSL_NONBLOCK_OCSP */