Let's suppose there is a client and a server, and the server sends a rekey request, or any other non-application data that might or might not be important (speaking generally here). I want to know if I am bound to sending and reading data for OpenSSL so that I can make my life and code simpler. To let you understand what I mean, I prepared these examples:
Suppose we succeeded with the TLS handshake and are now ready to exchange data. The client sends a HTTP request to the server, with Connection header set to close, meaning it won't send any more requests. Now OpenSSL would like to do something under the hood, and thus asking for sending. Maybe we did shutdown(SHUT_WR) and can't do that, or the kernel buffer is permanently full.
Suppose a game which exchanges lots of data - server sends information about the game to the clients, and clients send information about mouse and keyboard to the server. Normally, during the data exchanges, OpenSSL will have more than enough opportunities to do anything it would like, so actually there shouldn't be any need to explicitly listen to it's WANTS_something requests. Now, what if a client becomes AFK, so that it doesn't send any keyboard and mouse information, but OpenSSL wanted to do something that requires us to send something (if there could be such an event).
Both of the above scenarios have a shared idea in mind. The question is: can OpenSSL keep sending/receiving user data without sending/receiving TLS data? Or is it a requirement for the application to fulfill OpenSSL's requests to maintain a healthy connection/encryption?
If it is required to fulfill it's requests, there is another problem I might have with coding that. Suppose it asks for a read to process non-application data, but first in queue is actually application-data. I always want to read application data only when the application asks to do so, otherwise it is quite pointless, because we buffer data that we might not actually use and the peer will keep sending data, because the TCP congestion window will not shrink (since we read the data). Or, OpenSSL will buffer the application data internally, which is the same scenario, because eventually I will need to flush the data out of it to process more non-application data. Is there any flag or a way of processing ONLY non-application data? Is there any other cool solution to this?
And yes, I do understand that it is required for non-application data to be sent during the handshake and shutdown.