Fixes ICE failed case where Gmail user calls to Jitsi ones with SSLTCP only (when connecting to remote SSLTCP relay, the SSL handshake was not done).
This commit is contained in:
parent
ee0c31e444
commit
1d8fd98bd5
@ -13,6 +13,7 @@ import java.util.*;
|
||||
import java.util.logging.*;
|
||||
|
||||
import org.ice4j.*;
|
||||
import org.ice4j.ice.harvest.*;
|
||||
import org.ice4j.socket.*;
|
||||
|
||||
/**
|
||||
@ -251,7 +252,7 @@ public class Component
|
||||
continue;
|
||||
}
|
||||
|
||||
Socket sock = new MultiplexingSocket();
|
||||
MultiplexingSocket sock = new MultiplexingSocket();
|
||||
try
|
||||
{
|
||||
// if we use proxy (socks5, ...), the connect() timeout
|
||||
@ -272,6 +273,25 @@ public class Component
|
||||
continue;
|
||||
}
|
||||
|
||||
if(candidate.getTransportAddress().getPort() == 443)
|
||||
{
|
||||
//SSLTCP handshake
|
||||
OutputStream outputStream =
|
||||
sock.getOriginalOutputStream();
|
||||
InputStream inputStream = sock.getOriginalInputStream();
|
||||
|
||||
if(!GoogleTurnSSLCandidateHarvester.sslHandshake(
|
||||
inputStream, outputStream))
|
||||
{
|
||||
logger.info("Failed to connect to SSLTCP relay");
|
||||
outputStream = null;
|
||||
inputStream = null;
|
||||
continue;
|
||||
}
|
||||
outputStream = null;
|
||||
inputStream = null;
|
||||
}
|
||||
|
||||
LocalCandidate tmp =
|
||||
new HostCandidate(new IceTcpSocketWrapper(sock),
|
||||
this, Transport.TCP);
|
||||
|
||||
@ -127,16 +127,9 @@ public class GoogleTurnSSLCandidateHarvester
|
||||
stunServer.getPort());
|
||||
|
||||
OutputStream outputStream = sock.getOutputStream();
|
||||
outputStream.write(SSL_CLIENT_HANDSHAKE);
|
||||
|
||||
InputStream inputStream = sock.getInputStream();
|
||||
byte data[] = new byte[SSL_SERVER_HANDSHAKE.length];
|
||||
inputStream.read(data);
|
||||
|
||||
outputStream = null;
|
||||
inputStream = null;
|
||||
|
||||
if(Arrays.equals(data, SSL_SERVER_HANDSHAKE))
|
||||
if(sslHandshake(inputStream, outputStream))
|
||||
{
|
||||
cand = new HostCandidate(new IceTcpSocketWrapper(
|
||||
new MultiplexingSocket(sock)),
|
||||
@ -155,4 +148,34 @@ public class GoogleTurnSSLCandidateHarvester
|
||||
|
||||
return cand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the SSL handshake (send client certificate and wait for receive server
|
||||
* certificate). We explicitely need <tt>InputStream</tt> and
|
||||
* <tt>OutputStream</tt> because some <tt>Socket</tt> may redefine
|
||||
* getInputStream()/getOutputStream() and we need the original stream.
|
||||
*
|
||||
* @param inputStream <tt>InputStream</tt> of the socket
|
||||
* @param outputStream <tt>OuputStream</tt> of the socket
|
||||
* @return true if the SSL handshake is done
|
||||
* @throws IOException if something goes wrong
|
||||
*/
|
||||
public static boolean sslHandshake(InputStream inputStream, OutputStream
|
||||
outputStream) throws IOException
|
||||
{
|
||||
byte data[] = new byte[SSL_SERVER_HANDSHAKE.length];
|
||||
|
||||
outputStream.write(SSL_CLIENT_HANDSHAKE);
|
||||
inputStream.read(data);
|
||||
|
||||
outputStream = null;
|
||||
inputStream = null;
|
||||
|
||||
if(Arrays.equals(data, SSL_SERVER_HANDSHAKE))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -531,4 +531,28 @@ public class MultiplexingSocket
|
||||
|
||||
return outputStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get original <tt>InputStream</tt>.
|
||||
*
|
||||
* @return original <tt>InputStream</tt>
|
||||
* @throws IOException if something goes wrong
|
||||
*/
|
||||
public InputStream getOriginalInputStream()
|
||||
throws IOException
|
||||
{
|
||||
return super.getInputStream();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get original <tt>OutputStream</tt>.
|
||||
*
|
||||
* @return original <tt>OutputStream</tt>
|
||||
* @throws IOException if something goes wrong
|
||||
*/
|
||||
public OutputStream getOriginalOutputStream()
|
||||
throws IOException
|
||||
{
|
||||
return super.getOutputStream();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user