Skip to content

net: sockets: tls: Prevent infinite block during handshake #78492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions subsys/net/lib/sockets/sockets_tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -2181,8 +2181,9 @@
/* TODO For simplicity, TLS handshake blocks the socket
* even for non-blocking socket.
*/
ret = tls_mbedtls_handshake(ctx, K_FOREVER);
ret = tls_mbedtls_handshake(
ctx, K_MSEC(CONFIG_NET_SOCKETS_CONNECT_TIMEOUT));
if (ret < 0) {

Check notice on line 2186 in subsys/net/lib/sockets/sockets_tls.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/net/lib/sockets/sockets_tls.c:2186 - ret = tls_mbedtls_handshake( - ctx, K_MSEC(CONFIG_NET_SOCKETS_CONNECT_TIMEOUT)); + ret = tls_mbedtls_handshake(ctx, K_MSEC(CONFIG_NET_SOCKETS_CONNECT_TIMEOUT));
goto error;
}

Expand Down Expand Up @@ -2238,8 +2239,9 @@
/* TODO For simplicity, TLS handshake blocks the socket even for
* non-blocking socket.
*/
ret = tls_mbedtls_handshake(child, K_FOREVER);
ret = tls_mbedtls_handshake(
child, K_MSEC(CONFIG_NET_SOCKETS_CONNECT_TIMEOUT));
if (ret < 0) {

Check notice on line 2244 in subsys/net/lib/sockets/sockets_tls.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/net/lib/sockets/sockets_tls.c:2244 - ret = tls_mbedtls_handshake( - child, K_MSEC(CONFIG_NET_SOCKETS_CONNECT_TIMEOUT)); + ret = tls_mbedtls_handshake(child, K_MSEC(CONFIG_NET_SOCKETS_CONNECT_TIMEOUT));
goto error;
}

Expand Down Expand Up @@ -2379,6 +2381,9 @@

/* TODO For simplicity, TLS handshake blocks the socket even for
* non-blocking socket.
* DTLS handshake timeout/retransmissions are limited by
* mbed TLS, so K_FOREVER is fine here, the function will not
* block indefinitely.
*/
ret = tls_mbedtls_handshake(ctx, K_FOREVER);
if (ret < 0) {
Expand Down
Loading