Added timeout to SSL handshake in transport_mbedtls.c (#1405)

* Added timeout to SSL handshake in transport_mbedtls.c

---------

Co-authored-by: Aniruddha Kanhere <kanherea@amazon.com>
This commit is contained in:
Christian Jensen
2026-04-23 22:16:18 +02:00
committed by GitHub
parent 675335bf6a
commit 1495a812e4

View File

@@ -599,11 +599,16 @@ static TlsTransportStatus_t tlsHandshake( NetworkContext_t * pNetworkContext,
if( returnStatus == TLS_TRANSPORT_SUCCESS )
{
/* Perform the TLS handshake. */
TickType_t handshakeTimeoutTicks = pdMS_TO_TICKS( 10000 );
TimeOut_t handshakeStart;
vTaskSetTimeOutState( &handshakeStart );
do
{
mbedtlsError = mbedtls_ssl_handshake( &( pTlsTransportParams->sslContext.context ) );
} while( ( mbedtlsError == MBEDTLS_ERR_SSL_WANT_READ ) ||
( mbedtlsError == MBEDTLS_ERR_SSL_WANT_WRITE ) );
} while( ( ( mbedtlsError == MBEDTLS_ERR_SSL_WANT_READ ) ||
( mbedtlsError == MBEDTLS_ERR_SSL_WANT_WRITE ) ) &&
( xTaskCheckForTimeOut( &handshakeStart, &handshakeTimeoutTicks ) == pdFALSE ) );
if( mbedtlsError != 0 )
{