SSL_accept doesn't retry BIO_write

Detlef Vollmann dv at vollmann.ch
Sat May 4 21:54:51 UTC 2024


Hello,

I'm trying to write a non-blocking UDP based BIO to use
for a DTLS connection.
When the write() is called then the data is placed for transmission
and '0' is returned.  The respective OpenSSL function returns -1
with SSL_ERROR_WANT_WRITE.
When the data is actually put on the wire a function is called that 
calls the OpenSSL again that then retries the write.  This time
the BIO's write returns '1'.

Now it turns out that at the end of the DTLS handshake (even after
SSL_accept returned success, in Wireshark it looks like the
session key) OpenSSL still send data via the BIO's write, but it
looks like the last packet is never retried.  Instead OpenSSL
calls the BIO's control functionwith BIO_CTRL_FLUSH.

Now I treat the flush as 'OpenSSL isn't interested in the result
of the last write anymore'.  I'm not sure this assumption is correct,
but it seems to work... (Well, it could cause duplicate messages
if OpenSSL sends a flush but still retries the last write, but
this is UDP and both ends need to deal with duplicates (and losses)
anyways.

Is this approach ok or have I missed something?

   Detlef


More information about the openssl-users mailing list