      nsSocketTransportService *serv = gSocketTransportService;
      NS_RELEASE(serv); // nulls argument
  }
-@@ -1155,11 +1304,44 @@ nsSocketTransport::InitiateSocket()
-     // 
-     // Initiate the connect() to the host...  
-     //
+@@ -968,9 +1118,42 @@ nsSocketTransport::BuildSocket(PRFileDesc *&fd, PRBool &proxyTransparent, PRBool
+     proxyTransparent = PR_FALSE;
+     usingSSL = PR_FALSE;
+ 
++    fprintf(stderr, "BuildSocket: mTypeCount:%d\n", mTypeCount);
+     if (mTypeCount == 0) {
+-        fd = PR_OpenTCPSocket(mNetAddr.raw.family);
+-        rv = fd ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
++        if (mTLSTransport && mProxyHost.IsEmpty()) {
++            fprintf(stderr, "Building TLS socket to: %u\n", mPort);
++
++            nsCOMPtr<nsISocketProviderService> spserv =
++                do_GetService(kSocketProviderServiceCID, &rv);
++            if (NS_FAILED(rv)) return rv;
++
++            nsCOMPtr<nsISocketProvider> provider;
++            rv = spserv->GetSocketProvider("ssl", getter_AddRefs(provider));
++            if (NS_FAILED(rv))
++                return rv;
++
++            nsCOMPtr<nsISupports> secinfo;
++            rv = provider->NewSocket(mNetAddr.raw.family,
++                                     mHost.get(), mPort, nsnull, 0, 0,
++                                     &fd, getter_AddRefs(secinfo));
++
++            if (NS_SUCCEEDED(rv) && !fd) {
++                NS_NOTREACHED("NewSocket succeeded but failed to create a PRFileDesc");
++                return NS_ERROR_UNEXPECTED;
++            }
++
++            nsCOMPtr<nsISSLSocketControl> secCtrl(do_QueryInterface(secinfo));
++            if (!secCtrl) {
++                NS_NOTREACHED("Failed to get secCtrl");
++                return NS_ERROR_UNEXPECTED;
++            }
++            secCtrl->SetIgnoreAllCertErrors(true);
++
++            return NS_OK;
++        } else {
++          fd = PR_OpenTCPSocket(mNetAddr.raw.family);
++          rv = fd ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
++        }
+     }
+     else {
+         fd = nsnull;
+@@ -1027,6 +1210,7 @@ nsSocketTransport::BuildSocket(PRFileDesc *&fd, PRBool &proxyTransparent, PRBool
+ 
+             // if the service was ssl or starttls, we want to hold onto the socket info
+             PRBool isSSL = (strcmp(mTypes[i], "ssl") == 0);
++            fprintf(stderr, "isSSL: %d\n", isSSL);
+             if (isSSL || (strcmp(mTypes[i], "starttls") == 0)) {
+                 // remember security info and give notification callbacks to PSM...
+                 nsCOMPtr<nsIInterfaceRequestor> callbacks;
+@@ -1100,6 +1284,39 @@ nsSocketTransport::InitiateSocket()
+         return rv;
+     }
+ 
 +    struct obstcp_keys *const keys = ns_obstcp_get_keys();
 +
 +    if (mProxyPort == 0 && strlen(mHost.get()) && mPort == 80 && mDNSRecord) {
 +        nsCString advert;
 +        nsresult r = mDNSRecord->GetAdvert(advert);
 +        if (NS_SUCCEEDED(r)) {
-+            int newport;
-+
-+            if (obstcp_advert_base32_parse
-+                (advert.get(), advert.Length(),
-+                 OBSTCP_ADVERT_OBSPORT, &newport,
-+                 OBSTCP_ADVERT_END) &&
-+                newport) {
-+
++            int newport, tlsport;
++
++            int a = obstcp_advert_base32_parse
++                      (advert.get(), advert.Length(),
++                       OBSTCP_ADVERT_OBSPORT, &newport,
++                       OBSTCP_ADVERT_TLSPORT, &tlsport,
++                       OBSTCP_ADVERT_END);
++            if (a && newport) {
 +                mNetAddr.inet.port = htons(newport);
 +                mObfuscation = 1;
 +                PRUint8 random[16];

 
     PR_STATIC_CALLBACK(void) ThreadFunc(void *);
 
diff --git a/toolkit/library/Makefile.in b/toolkit/library/Makefile.in
index 7b00f11..d30494c 100644
--- a/toolkit/library/Makefile.in

diff --git a/netwerk/base/src/nsSocketTransport2.cpp b/netwerk/base/src/nsSocketTransport2.cpp
index e81a367..d70ed5a 100644
--- a/netwerk/base/src/nsSocketTransport2.cpp
+++ b/netwerk/base/src/nsSocketTransport2.cpp
@@ -48,6 +48,8 @@
