Commit 1f028b7d authored by jiayl@chromium.org's avatar jiayl@chromium.org

Fix the hostname used to setup a TURN/TSL connection.

BUG=https://code.google.com/p/webrtc/issues/detail?id=3601

Review URL: https://codereview.chromium.org/466843002

Cr-Commit-Position: refs/heads/master@{#289972}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289972 0039d316-1c4b-4281-b951-d872f2087c98
parent ec1fbde6
......@@ -186,16 +186,16 @@ void P2PSocketHostTcpBase::StartTls() {
// Default ssl config.
const net::SSLConfig ssl_config;
net::HostPortPair dest_host_port_pair;
if (remote_address_.ip_address.address().empty()) {
DCHECK(!remote_address_.hostname.empty());
dest_host_port_pair = net::HostPortPair::FromString(
remote_address_.hostname);
// Calling net::HostPortPair::FromIPEndPoint will crash if the IP address is
// empty.
if (!remote_address_.ip_address.address().empty()) {
net::HostPortPair::FromIPEndPoint(remote_address_.ip_address);
} else {
dest_host_port_pair = net::HostPortPair::FromIPEndPoint(
remote_address_.ip_address);
if (!remote_address_.hostname.empty())
dest_host_port_pair.set_host(remote_address_.hostname);
dest_host_port_pair.set_port(remote_address_.ip_address.port());
}
if (!remote_address_.hostname.empty())
dest_host_port_pair.set_host(remote_address_.hostname);
net::ClientSocketFactory* socket_factory =
net::ClientSocketFactory::GetDefaultFactory();
......
......@@ -235,18 +235,24 @@ bool IpcPacketSocket::Init(P2PSocketType type,
}
net::IPEndPoint remote_endpoint;
if (!remote_address.IsNil() && !jingle_glue::SocketAddressToIPEndPoint(
remote_address, &remote_endpoint) && !IsTcpClientSocket(type_)) {
// Non TCP sockets must have a resolved remote address.
return false;
if (!remote_address.IsNil()) {
DCHECK(IsTcpClientSocket(type_));
if (remote_address.IsUnresolvedIP()) {
remote_endpoint =
net::IPEndPoint(net::IPAddressNumber(), remote_address.port());
} else {
if (!jingle_glue::SocketAddressToIPEndPoint(remote_address,
&remote_endpoint)) {
return false;
}
}
}
// We need to send both resolved and unresolved address in Init. Unresolved
// address will be used in case of TLS for certificate hostname matching.
// Certificate will be tied to domain name not to IP address.
std::string remote_hostname = remote_address.hostname() + ":" +
remote_address.PortAsString();
P2PHostAndIPEndPoint remote_info(remote_hostname, remote_endpoint);
P2PHostAndIPEndPoint remote_info(remote_address.hostname(), remote_endpoint);
client->Init(type, local_endpoint, remote_info, this);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment