sockets - Does accept() return before TLS handshake is done in Java? -
i'm using java's ssl library secure connections between applications. , noted sslserversocket.accept()
returns socket if handshake fails.
- does mean
sslserversocket.accept()
won't wait until initial handshake done? and - if not, how can wait handshake done , detect clients failed handshake? or can start operating on new
sslsocket
, handshake completed automatically before actual operation?
also, writing , reading sslsockets (re)handshaking block until current handshake done? , if not, secure operate on handshaking sockets? handshake , application data sent parallel , not affecting each other?
accept()
not initiate handshake, merely returns accepted socket. handshake initiated when start performing i/o on accepted socket. documented behavior:
http://docs.oracle.com/javase/7/docs/api/javax/net/ssl/sslsocket.html
the initial handshake on connection can initiated in 1 of 3 ways:
- calling
starthandshake
explicitly begins handshakes, or- any attempt read or write application data on socket causes implicit handshake, or
- a call
getsession
tries set session if there no valid session, , implicit handshake done.if handshaking fails reason, sslsocket closed, , no futher communications can done.
...
when sslsockets first created, no handshaking done applications may first set communication preferences: cipher suites use, whether socket should in client or server mode, etc. however, security provided time application data sent on connection.
as handshake renegotiation, documented:
http://docs.oracle.com/javase/7/docs/api/javax/net/ssl/sslsocket.html#starthandshake()
if data has been sent on connection, continues flow during handshake. when handshake completes, signaled event. method synchronous initial handshake on connection , returns when negotiated handshake complete. protocols may not support multiple handshakes on existing socket , may throw ioexception.
Comments
Post a Comment