I'm upgrading a socket server written for non-blocking TCP sockets to use 
OpenSSL in non-blocking mode.

In the man page for SSL_read, the following is stated:

"When an SSL_read() operation has to be repeated because of SSL_ERROR_WANT_READ 
or SSL_ERROR_WANT_WRITE, it must be repeated with the same arguments."

There is no misunderstanding of that statement. It implies that the three 
parameters passed to this function (SSL, buffer, and length) must be the same 
each time.

But can there be an explanation for this?

I have a minor concern for converting many of the existing recv() calls to use 
SSL_read(). I can guarantee the length parameter is the same, but given the 
behavior of the code with regards to stack variables, it would be unsafe to 
assume that the buffer address is the same.

What would happen if after poll/select/epoll indicates new data, but the 
subsequent call to retry SSL_read passed in a different buffer address?  If the 
SSL function returns WANT_READ or WANT_WRITE, what is it doing under the hood 
to have to rely on identical parameters?

Why does the documentation for BIO_read not indicate a similar warning?

I'm also assuming it is save to have multiple SSL connection instances handled 
by the same thread - all using the same buffer for SSL_read (but never 
concurrently).  That would be my more likely workaround.

jrs


                                          

Reply via email to