3 years, 3 months ago.

Discovering the current/next step in mbedtls_ssl_handshake_step

Hi there,

I'm trying to write an asynchronous app on Linux using libev to progress the connection through getaddrinfo_a using non-blocking sockets (etc.), and have arranged for the read and write-handlers in the app to be managed independently by libev.

I'm calling mbedtls_ssl_handshake_step and had hoped that it would return MBEDTLS_ERR_SSL_WANT_READ or MBEDTLS_ERR_SSL_WANT_WRITE on each invocation; however, a lot of the time it just returns zero. Despite this, it appears to invoke my "net_send" function without first declaring that it wants to write. As a result, I'm having a hard time orchestrating writes to occur once a write notification is raised.

I would like to do this correctly, by which I mean that if I get a WANT_READ, then it is handled in-line when libev raises the EV_READ event, and, similarly, if mbedtls_ssl_handshake_step is due to perform a write, that that is handled when libev raises the EV_WRITE event.

Unfortunately, I don't know enough about the innards of the library to glean this information, and I would really appreciate any pointers on how to do this ... "properly".

Thanks very much,


Be the first to answer this question.