Skip to content

Commit 355bc45

Browse files
committed
Limit TLS 1.2 lock workaround
To affected versions. Signed-off-by: Peter M <petermm@gmail.com>
1 parent 6f44ff8 commit 355bc45

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/libAtomVM/otp_ssl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,11 +457,11 @@ static term nif_ssl_conf_authmode(Context *ctx, int argc, term argv[])
457457

458458
// MBEDTLS_SSL_VERIFY_NONE and MBEDTLS_SSL_VERIFY_OPTIONAL do not work with TLS 1.3
459459
// https://github.com/Mbed-TLS/mbedtls/issues/7075
460+
// Fixed in 3.6.1 https://github.com/Mbed-TLS/mbedtls/releases/tag/mbedtls-3.6.1
461+
// "Fixed by adding support for optional/none with TLS 1.3 as well."
460462
if (authmode != MBEDTLS_SSL_VERIFY_REQUIRED) {
461-
#if MBEDTLS_VERSION_NUMBER >= 0x03020000
463+
#if MBEDTLS_VERSION_NUMBER >= 0x03020000 && MBEDTLS_VERSION_NUMBER < 0x03060100
462464
mbedtls_ssl_conf_max_tls_version(&rsrc_obj->config, MBEDTLS_SSL_VERSION_TLS1_2);
463-
#else
464-
mbedtls_ssl_conf_max_version(&rsrc_obj->config, MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3);
465465
#endif
466466
}
467467

tests/libs/estdlib/test_ssl.erl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ is_ssl_available() ->
4949

5050
test_ssl() ->
5151
ok = ssl:start(),
52+
ok = test_print_client_capabilities(),
5253
ok = test_start_twice(),
5354
ok = test_connect_close(),
5455
ok = test_connect_error(),
@@ -57,6 +58,25 @@ test_ssl() ->
5758
ok = ssl:stop(),
5859
ok.
5960

61+
test_print_client_capabilities() ->
62+
{ok, SSLSocket} = ssl:connect("www.howsmyssl.com", 443, [
63+
{verify, verify_none}, {active, false}, {binary, true}
64+
]),
65+
UserAgent = erlang:system_info(machine),
66+
ok = ssl:send(SSLSocket, [
67+
<<"GET /a/check HTTP/1.1\r\nHost: www.howsmyssl.com\r\nUser-Agent: ">>, UserAgent, <<"\r\n\r\n">>
68+
]),
69+
{ok, <<"HTTP/1.1 200 OK", Return/binary>>} = ssl:recv(SSLSocket, 0),
70+
io:format("~s~n", [Return]),
71+
{ok, <<Return2/binary>>} = ssl:recv(SSLSocket, 0),
72+
io:format("~s~n", [Return2]),
73+
{ok, <<Return3/binary>>} = ssl:recv(SSLSocket, 0),
74+
io:format("~s~n", [Return3]),
75+
{ok, <<Return4/binary>>} = ssl:recv(SSLSocket, 0),
76+
io:format("~s~n", [Return4]),
77+
ok = ssl:close(SSLSocket),
78+
ok.
79+
6080
test_start_twice() ->
6181
ok = ssl:start().
6282

0 commit comments

Comments
 (0)