Remove bad cert listener code since it is no longer needed.
authorShawn Wilsher <sdwilsh@shawnwilsher.com>
Tue, 02 Mar 2010 15:15:39 -0800
changeset 43 9e49890b4d18f947ccdeba0b19bbd7f4eae461e0
parent 42 992016998cd5df8ada80eb432dab88bf375a01ae
child 44 fdd2984336e24e8947d17e03dbccf91a72c6ff86
push id23
push usersdwilsh@shawnwilsher.com
push dateWed, 03 Mar 2010 00:43:43 +0000
Remove bad cert listener code since it is no longer needed.
resource/BugzillaAPI.jsm
resource/BugzillaHelper.jsm
--- a/resource/BugzillaAPI.jsm
+++ b/resource/BugzillaAPI.jsm
@@ -131,31 +131,27 @@ const BugzillaAPI = {
 ////////////////////////////////////////////////////////////////////////////////
 //// BugzillaServer
 
 /**
  * Constructor for a server object that represents a bugzilla server.
  *
  * @param aURI
  *        The URI of the server.
- * @param aFingerprint
- *        The MD5 fingerprint of the certificate encrypting the connection.
  */
-function BugzillaServer(aURI,
-                        aFingerprint)
+function BugzillaServer(aURI)
 {
-  if (!aURI || !aFingerprint) {
+  if (!aURI) {
     throw new Components.Exception(
-      "Must provide a server and a fingerprint",
+      "Must provide a server",
       Cr.NS_ERROR_INVALID_ARG,
       Components.stack.caller
     );
   }
   this.uri = aURI;
-  this.fingerprint = aFingerprint;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 //// BugzillaAuth
 
 /**
  * Constructor for an authentication object that stores a username and password.
  *
@@ -184,76 +180,16 @@ BugzillaAuth.prototype = {
    */
   get authString()
   {
     return "username=" + this.username + "&password=" + this.password;
   },
 };
 
 ////////////////////////////////////////////////////////////////////////////////
-//// BadCertListener
-
-/**
- * @param aFingerprint
- *        The MD5 fingerprint of the certificate encrypting the connection.
- */
-function BadCertListener(aFingerprint)
-{
-  this._fingerprint = aFingerprint;
-  this.addedException = false;
-}
-
-BadCertListener.prototype = {
-  //////////////////////////////////////////////////////////////////////////////
-  //// nsIBadCertListener2
-
-  notifyCertProblem: function BCL_notifyCertProblem(aSocketInfo,
-                                                    aStatus,
-                                                    aTargetSite)
-  {
-    let certificate = aStatus.serverCert;
-    // Check to ensure that our fingerprint is what we expect.
-    if (certificate.md5Fingerprint != this._fingerprint)
-      return false;
-
-    // aTargetSite is a host:port combination.
-    let host, port;
-    let (items = aTargetSite.split(":")) {
-      host = items[0];
-      port = items[1];
-    };
-
-    // And add the exception.
-    const ERROR_UNTRUSTED = Ci.nsICertOverrideService.ERROR_UNTRUSTED;
-    let cow = Cc["@mozilla.org/security/certoverride;1"]
-              .getService(Ci.nsICertOverrideService);
-    cow.rememberValidityOverride(host, port, certificate, ERROR_UNTRUSTED,
-                                 true);
-    this.addedException = true;
-    return true;
-  },
-
-  //////////////////////////////////////////////////////////////////////////////
-  //// nsIInterfaceRequestor
-
-  getInterface: function BCL_getInterace(aIID)
-  {
-    return this.QueryInterface(aIID);
-  },
-
-  //////////////////////////////////////////////////////////////////////////////
-  //// nsISupports
-
-  QueryInterface: XPCOMUtils.generateQI([
-    Ci.nsIBadCertListener2,
-    Ci.nsIIntefaceRequestor,
-  ]),
-};
-
-////////////////////////////////////////////////////////////////////////////////
 //// Global Functions
 
 /**
  * Holds all pending outgoing messages.
  * XXX look into storing this in a database for atomicity.
  */
 let gOfflineQueue = [];
 
@@ -279,18 +215,16 @@ function performRequest(aServer,
   if (ioService.offline) {
     gOfflineQueue.push(arguments);
     return;
   }
 
   let channel = ioService.newChannel(aURI, null, null);
   channel.QueryInterface(Ci.nsIHttpChannel);
   channel.QueryInterface(Ci.nsIUploadChannel);
-  let bcl = new BadCertListener(aServer.fingerprint);
-  channel.notificationCallbacks = bcl;
   channel.QueryInterface(Ci.nsIHttpChannel);
   channel.setRequestHeader("Accept", "application/json", true);
   channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
   if (aData) {
     let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].
                     createInstance(Ci.nsIScriptableUnicodeConverter);
     converter.charset = "UTF-8";
     let is = converter.convertToInputStream(aData);
@@ -300,22 +234,16 @@ function performRequest(aServer,
 
   let (listener = Cc["@mozilla.org/network/simple-stream-listener;1"].
                   createInstance(Ci.nsISimpleStreamListener)) {
     let pipe = Cc["@mozilla.org/pipe;1"].createInstance(Ci.nsIPipe);
     pipe.init(true, true, 0, 0xffffffff, null);
     listener.init(pipe.outputStream, {
       onStartRequest: function(aRequest, aContext) { },
       onStopRequest: function(aRequest, aContext, aStatusCode) {
-        // It's possible we have a security error here.  If we do, see if we
-        // added an exception, and retry if we did.
-        if (aStatusCode == SEC_ERROR_UNKNOWN_ISSUER && bcl.addedException) {
-          performRequest(aServer, aURI, aCallback, aData);
-          return;
-        }
         pipe.outputStream.close();
         let is = Cc["@mozilla.org/scriptableinputstream;1"].
                  createInstance(Ci.nsIScriptableInputStream);
         is.init(pipe.inputStream);
 
         // available will throw if there is no data since we closed the output
         // end of the pipe.
         let len = 0;
--- a/resource/BugzillaHelper.jsm
+++ b/resource/BugzillaHelper.jsm
@@ -51,25 +51,23 @@ let EXPORTED_SYMBOLS = [
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
 
 /*
 // DEBUG constants
 const kBugzillaURI = "https://bugzilla-stage-tip.mozilla.org/";
 const kServer = new BugzillaServer(
-  "https://api-dev.bugzilla.mozilla.org/stage/0.3/",
-  "75:B2:EF:89:81:51:8F:99:13:DC:BF:44:47:0E:A9:8D"
+  "https://api-dev.bugzilla.mozilla.org/stage/0.3/"
 );
 */
 
 const kBugzillaURI = "https://bugzilla.mozilla.org/";
 const kServer = new BugzillaServer(
-  "https://api-dev.bugzilla.mozilla.org/0.3/",
-  "75:B2:EF:89:81:51:8F:99:13:DC:BF:44:47:0E:A9:8D"
+  "https://api-dev.bugzilla.mozilla.org/0.3/"
 );
 const kBugzillaRealm = "bugzilla-helper";
 
 ////////////////////////////////////////////////////////////////////////////////
 //// Globals
 
 this.__defineGetter__("activityManager", function() {
   delete this.activityManager;