Bug 1229013 - Cannot verify sender cert in smime signed received email since nsIPKIParamBlock went away. r=rkent a=jorgk
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Tue, 19 Jan 2016 22:02:26 +0200
changeset 26664 ed90831317205fbd8ed15d5aa3eaa64fadaa854c
parent 26663 ddc209117ac2f807b253a41921352182bcef3afe
child 26665 a17d1490f02068a03a18491dd7b9e313770807b9
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrkent, jorgk
bugs1229013
Bug 1229013 - Cannot verify sender cert in smime signed received email since nsIPKIParamBlock went away. r=rkent a=jorgk
mailnews/extensions/smime/content/msgReadSMIMEOverlay.js
mailnews/extensions/smime/content/msgReadSecurityInfo.js
--- a/mailnews/extensions/smime/content/msgReadSMIMEOverlay.js
+++ b/mailnews/extensions/smime/content/msgReadSMIMEOverlay.js
@@ -46,30 +46,30 @@ function showMessageReadSecurityInfo()
 {
   let gSignedUINode = document.getElementById("signedHdrIcon");
   if (gSignedUINode && gSignedUINode.getAttribute("signed") == "unknown")
   {
     showImapSignatureUnknown();
     return;
   }
 
-  let pkiParams = Components.classes["@mozilla.org/security/pkiparamblock;1"]
-                            .createInstance(Components.interfaces.nsIPKIParamBlock);
+  let params = Components.classes["@mozilla.org/embedcomp/dialogparam;1"]
+    .createInstance(Components.interfaces.nsIDialogParamBlock);
+  params.objects = Components.classes["@mozilla.org/array;1"]
+    .createInstance(Components.interfaces.nsIMutableArray);
+  // Append even if null... the receiver must handle that.
+  params.objects.appendElement(gSignerCert, false);
+  params.objects.appendElement(gEncryptionCert, false);
 
-  // isupport array starts with index 1
-  pkiParams.setISupportAtIndex(1, gSignerCert);
-  pkiParams.setISupportAtIndex(2, gEncryptionCert);
-
-  var params = pkiParams.QueryInterface(Components.interfaces.nsIDialogParamBlock);
   // int array starts with index 0, but that is used for window exit status
   params.SetInt(1, gSignatureStatus);
   params.SetInt(2, gEncryptionStatus);
 
   window.openDialog("chrome://messenger-smime/content/msgReadSecurityInfo.xul",
-                    "", "chrome,resizable=1,modal=1,dialog=1", pkiParams);
+                    "", "chrome,resizable,modal,dialog,centerscreen", params);
 }
 
 var SecurityController =
 {
   supportsCommand: function(command)
   {
     switch (command)
     {
--- a/mailnews/extensions/smime/content/msgReadSecurityInfo.js
+++ b/mailnews/extensions/smime/content/msgReadSecurityInfo.js
@@ -1,54 +1,48 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-var nsIPKIParamBlock = Components.interfaces.nsIPKIParamBlock;
 var nsIDialogParamBlock = Components.interfaces.nsIDialogParamBlock;
 var nsIX509Cert = Components.interfaces.nsIX509Cert;
 var nsICMSMessageErrors = Components.interfaces.nsICMSMessageErrors;
 var nsICertificateDialogs = Components.interfaces.nsICertificateDialogs;
 var nsCertificateDialogs = "@mozilla.org/nsCertificateDialogs;1"
 
 var gSignerCert = null;
 var gEncryptionCert = null;
 
 var gSignatureStatus = -1;
 var gEncryptionStatus = -1;
 
-var params = null;
-
 function setText(id, value) {
   var element = document.getElementById(id);
   if (!element)
     return;
   if (element.hasChildNodes())
     element.firstChild.remove();
   var textNode = document.createTextNode(value);
   element.appendChild(textNode);
 }
 
 function onLoad()
 {
-  var pkiParams = window.arguments[0].QueryInterface(nsIPKIParamBlock);
-  var isupport = pkiParams.getISupportAtIndex(1);
-  if (isupport) {
-    gSignerCert = isupport.QueryInterface(nsIX509Cert);
-  }
-  isupport = pkiParams.getISupportAtIndex(2);
-  if (isupport) {
-    gEncryptionCert = isupport.QueryInterface(nsIX509Cert);
-  }
+  var paramBlock = window.arguments[0].QueryInterface(nsIDialogParamBlock);
+  paramBlock.objects.QueryInterface(Components.interfaces.nsIMutableArray);
+  try {
+    gSignerCert = paramBlock.objects.queryElementAt(0, nsIX509Cert);
+  } catch(e) { } // maybe null
+  try {
+    gEncryptionCert = paramBlock.objects.queryElementAt(1, nsIX509Cert);
+  } catch(e) { } // maybe null
 
-  params = pkiParams.QueryInterface(nsIDialogParamBlock);
-
-  gSignatureStatus = params.GetInt(1);
-  gEncryptionStatus = params.GetInt(2);
+  gSignatureStatus = paramBlock.GetInt(1);
+  gEncryptionStatus = paramBlock.GetInt(2);
 
   var bundle = document.getElementById("bundle_smime_read_info");
 
   if (bundle) {
     var sigInfoLabel = null;
     var sigInfoHeader = null;
     var sigInfo = null;
     var sigInfo_clueless = false;
@@ -108,19 +102,21 @@ function onLoad()
       case nsICMSMessageErrors.VERIFY_NOCERT:
       case nsICMSMessageErrors.VERIFY_ERROR_UNVERIFIED:
       case nsICMSMessageErrors.VERIFY_ERROR_PROCESSING:
       case nsICMSMessageErrors.VERIFY_MALFORMED_SIGNATURE:
         sigInfoLabel = "SIInvalidLabel";
         sigInfoHeader = "SIInvalidHeader";
         sigInfo_clueless = true;
         break;
+      default:
+        Components.utils.reportError("Unexpected gSignatureStatus: " +
+                                     gSignatureStatus);
     }
 
-
     document.getElementById("signatureLabel").value = 
       bundle.getString(sigInfoLabel);
 
     var label;
     if (sigInfoHeader) {
       label = document.getElementById("signatureHeader");
       label.collapsed = false;
       label.value = bundle.getString(sigInfoHeader);
@@ -129,17 +125,16 @@ function onLoad()
     var str;
     if (sigInfo) {
       str = bundle.getString(sigInfo);
     }
     else if (sigInfo_clueless) {
       str = bundle.getString("SIClueless") + " (" + gSignatureStatus + ")";
     }
     setText("signatureExplanation", str);
-    
 
     var encInfoLabel = null;
     var encInfoHeader = null;
     var encInfo = null;
     var encInfo_clueless = false;
 
     switch (gEncryptionStatus) {
       case -1:
@@ -157,19 +152,21 @@ function onLoad()
         encInfo = "EIContentAltered";
         break;
 
       case nsICMSMessageErrors.GENERAL_ERROR:
         encInfoLabel = "EIInvalidLabel";
         encInfoHeader = "EIInvalidHeader";
         encInfo_clueless = 1;
         break;
+      default:
+        Components.utils.reportError("Unexpected gEncryptionStatus: " +
+                                     gEncryptionStatus);
     }
 
-
     document.getElementById("encryptionLabel").value = 
       bundle.getString(encInfoLabel);
 
     if (encInfoHeader) {
       label = document.getElementById("encryptionHeader");
       label.collapsed = false;
       label.value = bundle.getString(encInfoHeader);
     }