When a specific redirect is detected in the headers, read the certificate of that site and stop loading it (and later on send some certificate information in some other place).
All works well, except I can't read the certificate before the page is loaded. I use the fallowing code, which I traced out from the chrome:
Code: Select all
var ui = gBrowser.securityUI;
sp = ui.QueryInterface(Components.interfaces.nsISSLStatusProvider);
status = sp.SSLStatus;
status = status.QueryInterface(Components.interfaces.nsISSLStatus);
var cert = status.serverCert;
alert(cert.sha1Fingerprint);
This works perfectly if the page is currently loaded in the browser, but I need to do this before the page is loaded, cause I'm stopping it. I have also some other piece of code I've traced on the chrome, but something is just not right there (and I don't understand a big part of it):
Code: Select all
var params = Components.classes["@mozilla.org/embedcomp/dialogparam;1"].createInstance(Components.interfaces.nsIDialogParamBlock);
pkiParams = params.QueryInterface(Components.interfaces.nsIPKIParamBlock);
var isupport = pkiParams.getISupportAtIndex(1);
cert = isupport.QueryInterface(Components.interfaces.nsIX509Cert);
alert(cert.sha1Fingerprint);
The last part is not working at all, but I know that something like this I should do for my ext to work (this is from when the browser displays the unknown issuer of an certificate, and I noticed that this is done in the C++ code (nsNSSDialogs::ConfirmUnknownIssuer).
Can anyone help me make the last piece of code work (I don't manage to get right that "params" attribute (i noticed that is passed as a variable "block" in the C++ code on the openDialog method)), or can give me another pice of code wich will do the trick?