I don't think that any if the existing libraries gives you comfortable way to do this. At the end you have to fiddle around with various BIO_read, BIO_write and various other BIO_xxx methods. You might have a look at the source code of AnyEvent (especially AnyEvent::TLS and AnyEvent::Handle) to get the idea how this can be done.