Bug 650892 - [autoconfig] Can't create accounts - fails at around the time of searching the ISP database (getService fails in guessConfig.js). r=bwinton
authorMark Banner <bugzilla@standard8.plus.com>
Tue, 26 Apr 2011 21:48:06 +0100
changeset 7627 31ad9acf5213
parent 7626 0a5aa0741361
child 7628 0c9c4a20b02a
push id5851
push userbugzilla@standard8.plus.com
push date2011-04-26 20:50 +0000
treeherdercomm-central@31ad9acf5213 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwinton
bugs650892
Bug 650892 - [autoconfig] Can't create accounts - fails at around the time of searching the ISP database (getService fails in guessConfig.js). r=bwinton
mailnews/base/prefs/content/accountcreation/guessConfig.js
--- a/mailnews/base/prefs/content/accountcreation/guessConfig.js
+++ b/mailnews/base/prefs/content/accountcreation/guessConfig.js
@@ -32,18 +32,16 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-var gOverrideService = Cc["@mozilla.org/security/certoverride;1"]
-                       .getService(Ci.nsICertOverrideService);
 Cu.import("resource:///modules/gloda/log4moz.js");
 
 const TIMEOUT = 10; // in seconds
 
 // This is a bit ugly - we set outgoingDone to false
 // when emailWizard.js cancels the outgoing probe because the user picked
 // an outoing server. It does this by poking the probeAbortable object,
 // so we need outgoingDone to have global scope.
@@ -489,25 +487,25 @@ HostDetector.prototype =
 
   /**
    * @param thisTry {HostTry}
    * @param wiredata {Array of {String}} what the server returned
    *     in response to our protocol chat
    */
   _processResult : function(thisTry, wiredata)
   {
-    if (thisTry._gotCertError == gOverrideService.ERROR_MISMATCH)
+    if (thisTry._gotCertError == Ci.nsICertOverrideService.ERROR_MISMATCH)
     {
       thisTry._gotCertError = false;
       thisTry.status = kFailed;
       return;
     }
 
-    if (thisTry._gotCertError == gOverrideService.ERROR_UNTRUSTED ||
-        thisTry._gotCertError == gOverrideService.ERROR_TIME)
+    if (thisTry._gotCertError == Ci.nsICertOverrideService.ERROR_UNTRUSTED ||
+        thisTry._gotCertError == Ci.nsICertOverrideService.ERROR_TIME)
     {
       this._log.info("TRYING AGAIN, hopefully with exception recorded");
       thisTry._gotCertError = false;
       thisTry.selfSignedCert = true; // _next_ run gets this exception
       thisTry.status = kNotTried; // try again (with exception)
       this._tryAll();
       return;
     }
@@ -527,17 +525,19 @@ HostDetector.prototype =
       thisTry.status = kFailed;
       return;
     }
     if (thisTry.selfSignedCert)
     {
       // the callback will put up the cert exception dialog, so
       // clear the override here.
       this._log.info("clearing validity override for " + thisTry.hostname);
-      gOverrideService.clearValidityOverride(thisTry.hostname, thisTry.port);
+      Cc["@mozilla.org/security/certoverride;1"]
+        .getService(Ci.nsICertOverrideService)
+        .clearValidityOverride(thisTry.hostname, thisTry.port);
     }
     this._log.info("success with " + thisTry.hostname + ":" +
         thisTry.port + " " + protocolToString(thisTry.protocol) +
         " ssl " + thisTry.ssl +
         (thisTry.selfSignedCert ? " (selfSignedCert)" : ""));
     thisTry.status = kSuccess;
   },
 
@@ -928,18 +928,18 @@ SSLErrorHandler.prototype =
     let cert = status.QueryInterface(Ci.nsISSLStatus).serverCert;
     let flags = 0;
 
     let parts = targetSite.split(":");
     let host = parts[0];
     let port = parts[1];
 
     if (status.isDomainMismatch) {
-      this._try._gotCertError = gOverrideService.ERROR_MISMATCH;
-      flags |= gOverrideService.ERROR_MISMATCH;
+      this._try._gotCertError = Ci.nsICertOverrideService.ERROR_MISMATCH;
+      flags |= Ci.nsICertOverrideService.ERROR_MISMATCH;
 
       // If it was just a domain mismatch error
       // TODO "just"??? disabling it for now
       if (false && !(status.isUntrusted || status.isNotValidAtThisTime)) {
         // then, if we didn't get a wildcard in the certificate,
         if (cert.commonName.charAt(0) != "*") {
           // then add this host to the hosts to try, and skip to the end.
           /* TODO This is logically broken, I think
@@ -956,33 +956,35 @@ SSLErrorHandler.prototype =
             this._hostsToTry.push(cert.commonName);
           this._tryIndex = this.tryOrder.length - 1;
         }
         return true;
       }
     }
 
     if (status.isUntrusted) {
-      this._try._gotCertError = gOverrideService.ERROR_UNTRUSTED;
-      flags |= gOverrideService.ERROR_UNTRUSTED;
+      this._try._gotCertError = Ci.nsICertOverrideService.ERROR_UNTRUSTED;
+      flags |= Ci.nsICertOverrideService.ERROR_UNTRUSTED;
     }
     if (status.isNotValidAtThisTime) {
-      this._try._gotCertError = gOverrideService.ERROR_TIME;
-      flags |= gOverrideService.ERROR_TIME;
+      this._try._gotCertError = Ci.nsICertOverrideService.ERROR_TIME;
+      flags |= Ci.nsICertOverrideService.ERROR_TIME;
     }
 
     // If domain mismatch, then we shouldn't accept, and instead try the domain
     // in the cert to the list of tries.
     // Not skipping mismatches for now because it's too common, and until we can
     // poke around the cert and find out what domain to try, best to live
     // w/ orange than red.
 
     this._try.targetSite = targetSite;
     this._try._certOverrideProcessed = false;
-    gOverrideService.rememberValidityOverride(host, port, cert, flags,
+    Cc["@mozilla.org/security/certoverride;1"]
+      .getService(Ci.nsICertOverrideService)
+      .rememberValidityOverride(host, port, cert, flags,
         false); // last bit is temporary -- should it be true? XXX
     this._log.warn("!! Overrode bad cert temporarily " + host + " " + port +
                    "flags = " + flags + "\n");
     return true;
   },
 
   processSSLError : function(socketInfo, status, targetSite)
   {