Topic: SSL_ERROR_WANT_READ after successful call to SSL_write()

I have set up wolfSSL to do an asynchronous connect/accept. The idea is that SSL data is sent immediately, and there is no blocking to receive; instead, the SSL data from the other side is handled when it arrives. This is working well; the only thing I had to work out was what happens after the connection is set up, but before any application data has been received. In this case, the last call to SSL_read() finished the connection handshake, and then (since there was no more data), the ssl->error is set to WANT_READ. Now if I call SSL_write, it will succeed, (it returns the number of bytes written, rather than a negative error number). However, when I call SSL_get_error(ssl, result), it still returns SSL_ERROR_WANT_READ (rather than the SSL_ERROR_NONE which would be returned by OpenSSL).

This is not really a bug so much as a difference between wolfSSL and OpenSSL, so I'm not sure if you want to fix it or not. I can just check the return value from SSL_write() and only call SSL_get_error() if SSL_write returns <= 0. Another option is to change the SSL_get_error(ssl, result) function so that it returns SSL_ERROR_NONE if result is > 0.

-Ken

Share

Re: SSL_ERROR_WANT_READ after successful call to SSL_write()

Thanks, you're right, having SSL_ERROR_NONE when result > 0 is more compatible with OpenSSL.  I've put it into our latest patch of our embedded SSL library which should be available tomorrow on github.

Share