diff --git a/src/internal.c b/src/internal.c index c2f18c5dd..29c62fe89 100644 --- a/src/internal.c +++ b/src/internal.c @@ -16528,6 +16528,23 @@ int SendCertificateStatus(WOLFSSL* ssl) #endif /* WOLFSSL_NO_TLS12 */ + +/* If secure renegotiation is disabled, this will always return false. + * Otherwise it checks to see if we are currently renegotiating. */ +static WC_INLINE int IsSCR(WOLFSSL* ssl) +{ +#ifndef HAVE_SECURE_RENEGOTIATION + (void)ssl; +#else /* HAVE_SECURE_RENEGOTIATION */ + if (ssl->secure_renegotiation && + ssl->secure_renegotiation->enabled && + ssl->options.handShakeState != HANDSHAKE_DONE) + return 1; +#endif /* HAVE_SECURE_RENEGOTIATION */ + return 0; +} + + int SendData(WOLFSSL* ssl, const void* data, int sz) { int sent = 0, /* plainText size */ @@ -16569,7 +16586,7 @@ int SendData(WOLFSSL* ssl, const void* data, int sz) } else #endif - if (ssl->options.handShakeState != HANDSHAKE_DONE) { + if (ssl->options.handShakeState != HANDSHAKE_DONE && !IsSCR(ssl)) { int err; WOLFSSL_MSG("handshake not complete, trying to finish"); if ( (err = wolfSSL_negotiate(ssl)) != WOLFSSL_SUCCESS) {