// Ok, let's overlay the tunnel socket with SSL.
SSLSocket socket =
(SSLSocket) getSocketFactory().createSocket(tunnel,host.getHostName(), port, true);
// register a callback for handshaking completion event
socket.addHandshakeCompletedListener(
new HandshakeCompletedListener() {
public void handshakeCompleted(HandshakeCompletedEvent event) {
}
});
return socket;