Topic: wolfSSL in a non-blocking embedded ssl I/O environment

Hello !
I'm trying to make wolfSSL embedded ssl work in an OS-less, non blocking I/o environment. Is a "superloop" app. Is the synchronization of many state machines, one of them read queued buffers to transmit, and transmit them.  The server state machine has to post data, leave the control of the state machine and then is state will be evaluated when the data is transmitted again.
My worried is about the handshaking. Since basically all it's done inside "makeHandshake()" in some moment it will block. Is there a build in option to avoid this behavior and make it work with this constraints.

Thank you in advance!

Share

2 (edited by RaulHuertas 2012-07-15 16:51:44)

Re: wolfSSL in a non-blocking embedded ssl I/O environment

Hi again!
I've been cheking the function:
int wolfSSL_accept(WOLFSSL* ssl)
Seems like I have to 'unroll' whe 'while' statemtns in the final switch:
switch (ssl->options.acceptState)
Any other built in alternative?

Share

Re: wolfSSL in a non-blocking embedded ssl I/O environment

Hi,

wolfSSL_accept works with both blocking and non-blocking I/O.  When the underlying I/O is non-blocking, wolfSSL_accept will return when the underlying I/O could not satisfy the needs of of wolfSSL_accept to continue the handshake.  In this case, a call to wolfSSL_get_error will yield either SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE.  The calling process must then repeat the call to wolfSSL_accept when data is available to read and wolfSSL will pick up where it left off.

You can look at the wolfSSL example server (./examples/server/server.c) for a usage example.

Best Regards,
Chris

Re: wolfSSL in a non-blocking embedded ssl I/O environment

Really? amazing! smile. And tell me, is it the same with wolf_write and wolf_read?

Share

Re: wolfSSL in a non-blocking embedded ssl I/O environment

Correct, wolfSSL_read and wolfSSL_write act the same way.  You can see this by looking at EmbedSend() and EmbedReceive() in ./src/io.c.

Regards,
Chris

Re: wolfSSL in a non-blocking embedded ssl I/O environment

Thank you so much for the information, has been of great value.

Share