Skip to content

samples/mbedtls_sslclient: Discards TLS records, handshake does not work #7502

@vakulgarg

Description

@vakulgarg

I encountered a scenario where TLS handshake got broken. The mbedtls stack discarded tls records assuming corrupt data.

Digging further, I found that the way the incoming TLS records have been fed to mbedtls stack is wrong. Specifically, in function tcp_rx() (inside mbedtls_sslclient/src/tcp.c), the function always copies 'read_bytes' of data in input buffer 'buf' even if the requested input len given in 'size' parameter is less than 'read_bytes'. This could cause buffer overflow. Further, mbedtls stack disards whatever extra (i.e. read_bytes - size) that has been copied in tcp_rx() in 'buf'.

Perhaps, it would have been simpler and user-friendly, if instead of net_context apis, POSIX style sockets had been used in this example.

Metadata

Metadata

Assignees

Labels

area: NetworkingbugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bug

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions