Skip to content

Miscellaneous implementation issues with Session handling #74

@AnthonyGrondin

Description

@AnthonyGrondin

I've been using this library for a while and noticed the following miscellaneous issues.
@ivmarkov I'm pinging you since these are related to parts of the library that you contributed.

No handling of TlsError::NoClientCertificate for async Session

TlsError::NoClientCertificate isn't handled for async Session. Instead, the related error code (-29824) is returned when a client makes a request to an async server without providing the required certificates.

Reproduce:

  1. Run async_server example with mTLS: SSID=<SSID> PASSWORD=<PASS> cargo +esp esp32s3 --example async_server -Fexamples-async,mtls
  2. Make a request to the IP address without providing client certificates
  3. Server will fail with:
WARN - MbedTLS error: -29824 / ffff8b80


====================== PANIC ======================
panicked at examples/async_server.rs:240:17:
MbedTlsError(-29824)

"Bad usage of mbedtls_ssl_set_bio()" when dropping session

When a client session is dropped, the following warnings occurs:

WARN - 1 (esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2127) Bad usage of mbedtls_ssl_set_bio()
WARN - 1 (esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:2847) mbedtls_ssl_flush_output() returned -28928 (-0x7100)
WARN - 1 (esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:4877) mbedtls_ssl_write_record() returned -28928 (-0x7100)
WARN - 1 (esp-mbedtls/esp-mbedtls-sys/mbedtls/library/ssl_msg.c:5745) mbedtls_ssl_send_alert_message() returned -28928 (-0x7100)

Reproduce:

  1. Build async_client with the following patch:
diff --git a/examples/async_client.rs b/examples/async_client.rs
index 6b3a583..7c003cb 100644
--- a/examples/async_client.rs
+++ b/examples/async_client.rs
@@ -163,7 +163,7 @@ async fn main(spawner: Spawner) -> ! {
         .unwrap()
         .with_hardware_rsa(peripherals.RSA);
 
-    tls.set_debug(0);
+    tls.set_debug(1);
 
     let mut session = Session::new(
         &mut socket,
@@ -207,6 +207,8 @@ async fn main(spawner: Spawner) -> ! {
     println!();
     println!("Done");
 
+    drop(session);
+
     #[allow(clippy::empty_loop)]
     loop {}
 }
  1. Run example: SSID=<SSID> PASSWORD=<PASS> cargo +esp esp32s3 --example async_client -Fexamples-async
  2. Wait for request and see the above warnings logged in the terminal

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions