Mbed forum

Mbed TLS driven by readable/writable events


(Per Malmberg) #1

Hi,

I’ve got a working implementation of what I call a SocketDispatcher, essentially a dedicated task that handles all network communication for all non-blocking sockets via select() calls, and subsequently calls readable and writable events on the respective sockets wrapper classes.

I’m now trying to add support for TLS using mbed TLS, but have ended up in a state where:

  • Handshake succeeds mbedtls_ssl_handshake() returns 0
  • One application payload is sent
  • One application payload is received.
  • Trying to send a second payload fails.

From reading the log output from mbedTLS (which I unfortunately don’t have access to right now) it seems it’s wanting to read five bytes, but they never arrive and the other end eventually close the connection.

The most relevant parts of my implementation is available here

My main questions, other than that I would appreciate another set of eyes on my code, is if there are any problems with working with mbedTLS in the way I do, i.e. using FD_ISSET() to determine when calling mbedtls_sslread/write?

Edit: Sorry, I realize I haven’t pushed the current version to GitHub and can’t do that until this evening. The question remains though.


(Ron Eldor) #2

HI @permal,

Thank you for your intrerest in Mbed TLS!

Mbed TLS supports event driven bio.
You will need o supply your own bio cllbacks to support that, to be implemented similar to asynchronous sockets.

You can see some information in the following articles and queries:

I recommend you read further articles in our Knowledge Base, as they could give you additional information, such as https://tls.mbed.org/kb/generic/abstraction-layers

Regards,
Mbed TLS Team member
Ron


(Per Malmberg) #3

Seems I got it to work :slight_smile:, thanks @roneld01