I use C to solve the current issue, so I'll refer to C functions. I prefer to get help forn C/C++, but other languages are also okayish (because I assume I can translate the solution to C/C++).
The problem:
Linux allows it to timestamp incoming network data either on the network card or in the kernel (https://www.kernel.org/doc/Documentation/networking/timestamping.txt).
An easy example code can be found here: https://raw.githubusercontent.com/majek/openonload/master/src/tests/onload/hwtimestamping/rx_timestamping.c
The most important detail is that this requires using the recvmsg function in the receiver-code. Now I would like to get those timestamps for a connection which uses SSL. For SSL I use OpenSSL and finally the function SSL_read to get data from the stream. Unfortnately, I don't see a way to get the timestamps without modifying OpenSSL, but I assume I'm wrong and it is possible to do it.
Maybe someone knows how that feature can be used in combination with OpenSSL?
Thanks a lot
OpenSSL doesn't support this directly, but you could write a custom BIO to do this. OpenSSL does all its network interaction via a BIO. Normally you just use one of the in-built ones and then set it on your
SSLobject viaSSL_set_bio:https://www.openssl.org/docs/man3.1/man3/SSL_set_bio.html
You can also have separate BIOs for the read and write side. So in your case you might just use an in-built BIO for the write side, and a custom one for the read side.
In outline what you need to do is create a custom
BIO_METHODusingBIO_meth_new:https://www.openssl.org/docs/man3.1/man3/BIO_meth_new.html
Set a custom network read function on it using
BIO_meth_set_readorBIO_meth_set_read_ex(described on the same man page as above). You may need to implement some of the other functions depending on how your BIO works. Your custom network read function would callrecvmsgand get the timestamps you are interested in.Construct your custom
BIOobject usingBIO_new()and pass your newly constructionBIO_METHODas an argument.Finally set your custom
BIOon the read side of theSSLobject usingSSL_set_bioorSSL_set0_rbio