Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
cert fingerprint identicon generation #32
  • Loading branch information
sibiantony committed Oct 26, 2016
1 parent 00334ea commit e163d82
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 17 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -65,3 +65,5 @@ mozilla guidelines for [modifiers](https://developer.mozilla.org/en-US/docs/XUL/

SSleuth is released under [GPLv3.0](https://www.gnu.org/licenses/gpl-3.0.html).
You should find the license text in the About page of add-on preferences.

Jdenticon 1.3.2 zlib license, jdenticon.com (c) Daniel Mester Pirttijärvi
9 changes: 8 additions & 1 deletion content/preferences.xul
Expand Up @@ -355,7 +355,7 @@
</groupbox>
<groupbox>
<caption label='&ssleuth.pref.about.thanks;' />
<description value=' • John Souvestre (beta tests)'/>
<description value=' • John Souvestre (beta tests, v0.3.1)'/>
<description value='&ssleuth.pref.about.translations;'/>
<description value=' • Jei Four (de-DE)' />
<description value=' • Thomas PORTASSAU (fr-FR) 0.4.x' />
Expand All @@ -376,6 +376,13 @@
but WITHOUT ANY WARRANTY. See the GNU General Public License for more details.
</description>

<description value=""/>

<description class="ssleuth-pref-text">
Jdenticon 1.3.2 zlib license, jdenticon.com (c) Daniel Mester Pirttijärvi
</description>


</groupbox>
</vbox>
</scrollbox>
Expand Down
6 changes: 3 additions & 3 deletions install.rdf
Expand Up @@ -6,7 +6,7 @@
<homepageURL>https://github.com/sibiantony/ssleuth/</homepageURL>
<id>ssleuth@github</id>
<name>SSleuth</name>
<version>0.5.1</version>
<version>0.5.2</version>
<iconURL>chrome://ssleuth/skin/ssleuth-icon.png</iconURL>
<optionsURL>chrome://ssleuth/content/preferences.xul</optionsURL>
<optionsType>3</optionsType>
Expand All @@ -30,7 +30,7 @@
<description>How strong is your HTTPS connection? SSleuth ranks an established SSL/TLS connection and provides a brief summary of the SSL/TLS parameters. Lets users tweak cipher suites status.</description>
</r:Description>
</localized>

<localized>
<r:Description>
<locale>pl-PL</locale>
Expand All @@ -40,4 +40,4 @@
</localized>

</r:Description>
</r:RDF>
</r:RDF>
13 changes: 13 additions & 0 deletions modules/lib/jdenticon.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 28 additions & 7 deletions modules/panel.js
Expand Up @@ -517,16 +517,37 @@ var panelbox = function (win) {
class: 'ssleuth-text-body-class'
}));
} {
let hb = vb.appendChild(elem('hbox', {
let hb1 = vb.appendChild(elem('hbox', {
id: 'ssleuth-text-cert-fingerprint-label-box',
align: 'baseline',
})); {
/* The fingerprint description will be a hidden element,
however will be needed in clipboard copies.
*/
hb1.appendChild(elem('description', {
id: 'ssleuth-text-cert-fingerprint-label',
value: utils.getText('certificate.fingerprint'),
class: 'ssleuth-text-title-class',
hidden: 'true'
}));
}
let hb2 = vb.appendChild(elem('hbox', {
id: 'ssleuth-text-cert-fingerprint-box',
align: 'baseline',
}));
hb.appendChild(elem('description', {
id: 'ssleuth-text-cert-fingerprint-label',
value: utils.getText('certificate.fingerprint'),
class: 'ssleuth-text-body-class'
})); {
let vb = hb.appendChild(elem('vbox', {
let chb = hb2.appendChild(elem('hbox', {
align: 'left',
width: IMG_MARGIN_WIDTH
}));

let canvas = doc.createElementNS('http://www.w3.org/1999/xhtml', 'canvas');
canvas.setAttribute('id', 'ssleuth-img-cert-fingerprint-identicon');
canvas.setAttribute('width', 55);
canvas.setAttribute('height', 55);

chb.appendChild(canvas);
} {
let vb = hb2.appendChild(elem('vbox', {
align: 'baseline',
flex: '1'
}));
Expand Down
60 changes: 54 additions & 6 deletions modules/ssleuth-ui.js
Expand Up @@ -26,9 +26,11 @@ var ui = (function () {
var startup = function (_prefs) {
prefs = _prefs;
loadStyleSheet();
identicon.init();
};

var shutdown = function () {
identicon.uninit();
removeStyleSheet();
};

Expand Down Expand Up @@ -167,6 +169,49 @@ var ui = (function () {

}());

var identicon = (function () {

var jdenticon;
var init = function () {
const {
require
} = Cu.import("resource://gre/modules/commonjs/toolkit/require.js", {});

jdenticon = require("resource://ssleuth/lib/jdenticon.min");
if (!jdenticon) {
log.error("No jdenticon library found!");
return;
}
jdenticon.config = {
lightness: {
color: [0.4, 0.8],
grayscale: [0.3, 0.7]
},
saturation: 0.6
};

};

var uninit = function () {
jdenticon = null;
};

var update = function (cert, doc) {

var fingerprint = cert.sha256Fingerprint.replace(/:/g, '');

var canvas = doc.getElementById('ssleuth-img-cert-fingerprint-identicon');
canvas.setAttribute('data-jdenticon-hash', fingerprint);
jdenticon.update(canvas);
};

return {
init: init,
uninit: uninit,
update: update
};
}());

function _ssleuthButton(win) {
if (ui.currentLocation == ui.buttonLocation.TOOLBAR) {
return win.document.getElementById('ssleuth-tb-button');
Expand Down Expand Up @@ -538,16 +583,16 @@ function showFFState(state, win) {
}

function showCertDetails(cert, domMismatch, ev, win) {
var svCert = cert.serverCert;
var validity = svCert.validity.QueryInterface(Ci.nsIX509CertValidity);
var doc = win.document;
var svCert = cert.serverCert,
validity = svCert.validity.QueryInterface(Ci.nsIX509CertValidity),
doc = win.document;
const rp = ui.prefs['rating.params'];
const panelInfo = ui.prefs['panel.info'];

doc.getElementById('ssleuth-text-cert-common-name').textContent = svCert.commonName;
var certRating = doc.getElementById('ssleuth-cert-status-rating');
var evRating = doc.getElementById('ssleuth-cert-ev-rating');
var elemEV = doc.getElementById('ssleuth-text-cert-extended-validation');
var certRating = doc.getElementById('ssleuth-cert-status-rating'),
evRating = doc.getElementById('ssleuth-cert-ev-rating'),
elemEV = doc.getElementById('ssleuth-text-cert-extended-validation');
if (ev) {
elemEV.textContent = utils.getText('general.yes');
elemEV.setAttribute('ev', 'Yes');
Expand Down Expand Up @@ -611,8 +656,11 @@ function showCertDetails(cert, domMismatch, ev, win) {
doc.getElementById('ssleuth-text-cert-fingerprint-3')
.textContent = svCert.sha256Fingerprint.substring(66);

identicon.update(svCert, doc);

doc.getElementById('ssleuth-text-cert-validity-box').hidden = !(panelInfo.certValidity);
doc.getElementById('ssleuth-text-cert-fingerprint-box').hidden = !(panelInfo.certFingerprint);

}

function showTLSVersion(win, tab) {
Expand Down

0 comments on commit e163d82

Please sign in to comment.