Skip to content

Commit 7d7d41b

Browse files
author
Ruslan Filipenko
committed
force to use at least TLS1.2 + some minor changes
1 parent 0bd7a14 commit 7d7d41b

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

lib/platform/marvell/marvell.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <stdarg.h>
1010

1111
#include <wm_net.h>
12+
#include <mbedtls/error.h>
13+
#include <mbedtls/net_sockets.h>
1214

1315

1416
void platform_timer_init(Timer* t)
@@ -135,6 +137,10 @@ static int tls_connect(Network* n, const char* hostname)
135137
return rc;
136138
}
137139

140+
mbedtls_ssl_conf_min_version(n->tls_config,
141+
MBEDTLS_SSL_MAJOR_VERSION_3,
142+
MBEDTLS_SSL_MINOR_VERSION_3);
143+
138144
mbedtls_ssl_conf_cert_profile(n->tls_config,
139145
&wm_mbedtls_x509_crt_profile_evrythng);
140146

@@ -291,12 +297,26 @@ int platform_network_read(Network* n, unsigned char* buffer, int len, int timeou
291297
bytes = 0;
292298
break;
293299
}
294-
else if (rc == -1)
300+
else if (rc < 0)
295301
{
296-
if (errno != ENOTCONN && errno != ECONNRESET)
302+
if (n->tls_enabled)
303+
{
304+
if (rc == MBEDTLS_ERR_SSL_TIMEOUT ||
305+
rc == MBEDTLS_ERR_NET_RECV_FAILED)
306+
{
307+
bytes = -1;
308+
break;
309+
}
310+
else
311+
platform_printf("mbedtls_ssl_read ret: -0x%02X\n", -rc);
312+
}
313+
else
297314
{
298-
bytes = -1;
299-
break;
315+
if (errno != ENOTCONN && errno != ECONNRESET)
316+
{
317+
bytes = -1;
318+
break;
319+
}
300320
}
301321
}
302322
else

0 commit comments

Comments
 (0)