Bug 1056934 - Part 6: Fix bug where TCPSocketParent would not use TLS when requested. r=mcmanus
authorByron Campen [:bwc] <docfaraday@gmail.com>
Tue, 03 Jan 2017 12:34:19 -0600
changeset 462762 a78433dca4bbdba58b232cea94251381b79a7549
parent 462761 c100d0ad4d4a8d6e5d5c1d35d09b853a733784c9
child 462763 d84bef0d3b096a523c979d24fccf25392c9fb231
push id41857
push userbmo:mh+mozilla@glandium.org
push dateWed, 18 Jan 2017 00:24:11 +0000
reviewersmcmanus
bugs1056934
milestone53.0a1
Bug 1056934 - Part 6: Fix bug where TCPSocketParent would not use TLS when requested. r=mcmanus MozReview-Commit-ID: EQHzJWyzAN9
dom/network/TCPSocketParent.cpp
--- a/dom/network/TCPSocketParent.cpp
+++ b/dom/network/TCPSocketParent.cpp
@@ -142,19 +142,28 @@ TCPSocketParent::RecvOpenBind(const nsCS
   nsCOMPtr<nsISocketTransportService> sts =
     do_GetService("@mozilla.org/network/socket-transport-service;1", &rv);
   if (NS_FAILED(rv)) {
     FireInteralError(this, __LINE__);
     return IPC_OK();
   }
 
   nsCOMPtr<nsISocketTransport> socketTransport;
-  rv = sts->CreateTransport(nullptr, 0,
-                            aRemoteHost, aRemotePort,
-                            nullptr, getter_AddRefs(socketTransport));
+  if (aUseSSL) {
+    const char* socketTypes[1];
+    socketTypes[0] = "ssl";
+    rv = sts->CreateTransport(socketTypes, 1,
+                              aRemoteHost, aRemotePort,
+                              nullptr, getter_AddRefs(socketTransport));
+  } else {
+    rv = sts->CreateTransport(nullptr, 0,
+                              aRemoteHost, aRemotePort,
+                              nullptr, getter_AddRefs(socketTransport));
+  }
+
   if (NS_FAILED(rv)) {
     FireInteralError(this, __LINE__);
     return IPC_OK();
   }
 
   // in most cases aReuseAddrPort is false, but ICE TCP needs
   // sockets options set that allow addr/port reuse
   socketTransport->SetReuseAddrPort(aReuseAddrPort);