> I'm writing a SSL proxy (which is working great except for this issue)
> and every time I got to attach a file in an email the connection resets,
> and it gets caught in an infinite retransmit loop.

There are two totally different ways you can make an SSL proxy, and to figure 
out your issue, we really need to know which type.

1) An SSL proxy can understand the underlying protocol, know which side is 
supposed to transmit when, and only try to read from that side. In this case, 
it's vital that the proxy correctly track the protocol and not be reading from 
one side when it's the other side's turn to send.

2) An SSL proxy can ignore the underlying protocol and not know which side is 
supposed to transmit when. In this case, the proxy must always be ready to read 
from either side. It must never block indefinitely trying to read from one side.

You can also have a hybrid. For example, you can read only from the client side 
until you get the full request, and then once you process the request, you 
switch to bidirectional proxying.

It is very common for people to naively assume that their code will magically 
know which side to read from. I assure, this is not the case. Unless you 
carefully track the protocol, all you know is that the client has to send some 
data first. But once it does, all bets are off -- again, unless you carefully 
track the protocol.

Also, you don't mention whether your I/O is blocking or non-blocking, and if 
non-blocking, how your socket discovery works. This can be subtle with OpenSSL 
and your mistake might lie there. For example, if you using blocking I/O, you 
can't just block one thread in SSL_read in each direction, because if you do, 
there's nothing you can do when SSL_read returns (since the connection you need 
to send on is in use, potentially indefinitely, by the other thread).

DS

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to