Clinton Foster wrote:
Yes, this agrees with what I am seeing. I'm not sure if this is a clean
solution, but adding the following code near the bottom of
FtpDataConnection.getDataSocket() is one way to resolve the problem:

            if (dataSoc instanceof SSLSocket) {
                ((SSLSocket)dataSoc).startHandshake();
            }
        }
        catch(Exception ex) {

I need to read up a bit on SSL sockets in Java to be sure, but it would
appear the handshake is triggered automatically when the first byte of data
is written to the socket. The above code forces the handshake to occur
immediately after the connection is completed. Thus, even if the server
closes the connection without writing anything to the socket, the client
does not complain of a handshake error.

The JavaDoc for SSLSocket says you're right:

The initial handshake on this connection can be initiated in one of three ways:

    * calling startHandshake which explicitly begins handshakes, or
* any attempt to read or write application data on this socket causes an implicit handshake, or * a call to getSession tries to set up a session if there is no currently valid session, and an implicit handshake is done.

http://java.sun.com/j2se/1.5.0/docs/api/javax/net/ssl/SSLSocket.html

The above fix looks reasonable, I'll get it in there as soon as I can (got some other changes I want to commit first). Thanks for the feedback!

/niklas

Reply via email to