Skip to content
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

Support TLS 1.3 #272

Open
kristiankielhofner opened this issue Sep 25, 2023 · 1 comment
Open

Support TLS 1.3 #272

kristiankielhofner opened this issue Sep 25, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@kristiankielhofner
Copy link
Contributor

We have initial IDF 5.1 support and it has a new mbedtls implementation that supports TLS 1.3. Unfortunately, it errors on HTTP stream to WIS/nginx when TLS 1.3 is enabled:

E (07:52:30.725) esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x6C00
E (07:52:30.726) esp-tls: Failed to open new connection
E (07:52:30.729) transport_base: Failed to open a new connection
E (07:52:30.737) HTTP_CLIENT: Connection failed, sock < 0
E (07:52:30.742) AUDIO_ELEMENT: [http_stream_writer] AEL_STATUS_ERROR_OPEN,-1
@stintel
Copy link
Collaborator

stintel commented Sep 27, 2023

It appears ESP-TLS does not support TLS 1.3 yet. Initial support was added in master: espressif/esp-idf@7fd1378.

After manually initializing the Mbed TLS PSA library and enabling CONFIG_MBEDTLS_DEBUG in sdkconfig, there's a different error:

W (20:32:56.020) mbedtls: ssl_tls13_generic.c:653 x509_verify_cert() returned -9984 (-0x2700)
W (20:32:56.021) mbedtls: ssl_tls13_generic.c:693 got no CA chain

So it appears CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY doesn't work anymore with TLS 1.3. This appears to be because of MBEDTLS_SSL_VERIFY_NONE not doing what's expected. MBEDTLS_SSL_VERIFY_OPTIONAL still works.
With the following change, cert verification is no longer a problem:

--- a/library/ssl_tls13_generic.c
+++ b/library/ssl_tls13_generic.c
@@ -571,7 +571,7 @@ MBEDTLS_CHECK_RETURN_CRITICAL
 static int ssl_tls13_validate_certificate(mbedtls_ssl_context *ssl)
 {
     int ret = 0;
-    int authmode = MBEDTLS_SSL_VERIFY_REQUIRED;
+    int authmode = MBEDTLS_SSL_VERIFY_OPTIONAL;
     mbedtls_x509_crt *ca_chain;
     mbedtls_x509_crl *ca_crl;
     const char *ext_oid;```

But then we hit the next error in esp_tls:

E (21:34:34.251) transport_base: esp_tls_conn_read error, errno=Connection already in progress
E (21:34:34.252) WILLOW/HTTP: failed to get HTTP headers

At this point it's probably better to wait for a new IDF release where it is properly supported.

@stintel stintel added the enhancement New feature or request label Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants