I am working on a Firefox extension that would display the SSL certificate information to the user. The actual information would be the same as the one built in to the browser, but I will be experimenting with layouts and other information for UX.
I've been working with Firefox extensions instead of add ons due to deprecation of add-ons in 2017, but this project will be finished before then.
I was trying the example found here, but the extension seems to stop on the require("chrome")
.
Next I tried writing simpler code to figure out how the example works, but this code doesn't have a channel attached to the request. My code, minus all sorts of printing statements, is below:
document.getElementById("click_button").addEventListener("click",
function(e) {
var url = "https://secure-website-example.google.com";
xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.addEventListener("error",
function(e) {
dumpSecurityInfo(xhr, -1);
}, false);
xhr.onload = function(e) {
dumpSecurityInfo(xhr);
};
xhr.send();
});
function dumpSecurityInfo(xhr, error) {
var channel = xhr.channel;
try {
console.log("Connection status:");
if (!error) { console.log("Succeeded"); }
else { console.log("Failed :("); }
var securityInfo = channel.securityInfo;
} catch(err) {
alert(err);
}
}
with a manifest like this:
"manifest_version": 2,
"name": "Certificate Browser",
"version": "1.0",
...
"permissions": [
"activeTab",
"webRequest",
"https://secure-website-example.google.com/*"
],
"browser_action": {
...
"default_popup": "popup/certificate_information.html"
}
Am I missing any permissions necessary to have access to the certificate? Is there a better way of grabbing certificate information?