in platform/posix/transport/src/mbedtls_pkcs11_posix.c [851:885]
void Mbedtls_Pkcs11_Disconnect( NetworkContext_t * pNetworkContext )
{
MbedtlsPkcs11Context_t * pMbedtlsPkcs11Context = NULL;
int tlsStatus = 0;
if( ( pNetworkContext != NULL ) && ( pNetworkContext->pParams != NULL ) )
{
pMbedtlsPkcs11Context = pNetworkContext->pParams;
/* Attempting to terminate TLS connection. */
tlsStatus = mbedtls_ssl_close_notify( &( pMbedtlsPkcs11Context->context ) );
if( tlsStatus == 0 )
{
LogInfo( ( "Closing TLS connection: TLS close-notify sent." ) );
}
else if( ( tlsStatus == MBEDTLS_ERR_SSL_WANT_READ ) ||
( tlsStatus == MBEDTLS_ERR_SSL_WANT_WRITE ) )
{
/* WANT_READ or WANT_WRITE can be ignored. Logging for debugging purposes. */
LogInfo( ( "TLS close-notify sent; "
"received %s as the TLS status which can be ignored for close-notify.",
( tlsStatus == MBEDTLS_ERR_SSL_WANT_READ ) ? "WANT_READ" : "WANT_WRITE" ) );
}
else
{
/* Ignore the WANT_READ or WANT_WRITE return values. */
LogError( ( "Failed to send TLS close-notify: mbedTLSError= %s : %s.",
mbedtlsHighLevelCodeOrDefault( tlsStatus ),
mbedtlsLowLevelCodeOrDefault( tlsStatus ) ) );
}
/* Free contexts. */
contextFree( pMbedtlsPkcs11Context );
}
}