Skip to content

Commit

Permalink
Add link to crt.sh on certificate fingerprint label
Browse files Browse the repository at this point in the history
  • Loading branch information
jannispinter committed Jan 30, 2020
1 parent f088931 commit ea5d372
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function updateIcon(tabId, protocolVersion) {
}

async function loadSavedSecurityInfoAndUpdateIcon(details) {
cached_version = tabMainProtocolMap.get(details.tabId);
cached_version = tabMainProtocolMap.get(details.tabId).protocolVersion;
if (typeof cached_version !== "undefined" && cached_version !== "unknown") {
await updateIcon(details.tabId, cached_version);
}
Expand All @@ -49,7 +49,7 @@ async function processSecurityInfo(details) {

// save the security info for the current tab and update the page action icon
if (details.type === 'main_frame') {
tabMainProtocolMap.set(details.tabId, securityInfo.protocolVersion);
tabMainProtocolMap.set(details.tabId, securityInfo);
await updateIcon(details.tabId, securityInfo.protocolVersion);
}

Expand Down
11 changes: 6 additions & 5 deletions popup/popup-primary.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@ function openTab(evt, tabName) {
evt.currentTarget.className += " active";
}


function updatePopupPrimaryTab(securityInfo, hostname) {
function updatePopupSecurityInfo(securityInfo, hostname) {
updateProtocolDetails(securityInfo, hostname);
updateCertificateDetails(securityInfo);
updateTranslations();
}

async function updateProtocolDetails(securityInfo, hostname) {
const textProtocolVersion = document.getElementById('popup-primary-protcol-version');
textProtocolVersion.textContent = securityInfo.protocolVersion;
textProtocolVersion.style.color = protocolColorMap.get(securityInfo.protocolVersion);
const textTlsProtocolVersion = document.getElementById('popup-primary-protcol-tls-version');
textTlsProtocolVersion.textContent = securityInfo.protocolVersion;
textTlsProtocolVersion.style.color = protocolColorMap.get(securityInfo.protocolVersion);
if(securityInfo.protocolVersion === 'TLSv1' || securityInfo.protocolVersion === 'SSLv3') {
setCheckmarkIconRed('popup-primary-icon-protocol');
} else if (securityInfo.protocolVersion === 'TLSv1.1') {
Expand Down Expand Up @@ -138,8 +137,10 @@ async function updateCertificateDetails(securityInfo) {

const textCertificateFingerprintFirstLine = document.getElementById('popup-primary-certificate-fingerprint-first-line');
const textCertificateFingerprintSecondLine = document.getElementById('popup-primary-certificate-fingerprint-second-line');
const textCertificateFingerprintCrtShUrl = document.getElementById('popup-primary-certificate-fingerprint-crt-sh-url');
textCertificateFingerprintFirstLine.textContent = serverCertificate.fingerprint.sha256.substr(0,48);
textCertificateFingerprintSecondLine.textContent = serverCertificate.fingerprint.sha256.substr(48);
textCertificateFingerprintCrtShUrl.href = "https://crt.sh/?q=" + serverCertificate.fingerprint.sha256;
}


Expand Down
8 changes: 6 additions & 2 deletions popup/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<table class="popup-primary">
<tr>
<td class="popup-primary-checkmark-column"><img id="popup-primary-icon-protocol" src="../icons/checkmark_green.png"/></td>
<td><strong><span id="popup-primary-title-tls-protocol"></span></strong> <span id="popup-primary-protcol-version">N/A</span></td>
<td><strong><span id="popup-primary-title-tls-protocol"></span></strong> <span id="popup-primary-protcol-tls-version">N/A</span></td>
</tr>
<tr>
<td class="popup-primary-checkmark-column"><img id="popup-primary-icon-connection-state" src="../icons/checkmark_green.png"/></td>
Expand Down Expand Up @@ -79,7 +79,11 @@
<td><span id="popup-primary-certificate-keylength">N/A</span></td>
</tr>-->
<tr>
<td style="vertical-align:top"><span id="popup-primary-title-certificate-fingerprint"></span></td>
<td style="vertical-align:top">
<a id="popup-primary-certificate-fingerprint-crt-sh-url" href="#">
<span id="popup-primary-title-certificate-fingerprint"></span>
</a>
</td>
<td>
<span id="popup-primary-certificate-fingerprint-first-line" class="selectable">N/A</span><br>
<span id="popup-primary-certificate-fingerprint-second-line" class="selectable">N/A</span>
Expand Down
9 changes: 6 additions & 3 deletions popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ function updatePopup(tabInfo) {
var subresourceMap = reply.requested_info;
for (const[domain, securityInfo] of subresourceMap.entries()) {
insertTableRow(domain, securityInfo);
if(domain === (new URL(tabInfo.url)).host) {
updatePopupPrimaryTab(securityInfo, domain);
}
}
includesResourcesFromLessSecureHosts(tabInfo, subresourceMap);
}).catch(error => console.error(error));

request('tabMainProtocolMap', tabInfo.id).then((reply) => {
const securityInfo = reply.requested_info;
const domain = (new URL(tabInfo.url)).host;
updatePopupSecurityInfo(securityInfo, domain);
}).catch(error => console.error(error));

}

browser.tabs.query({active: true, windowId: browser.windows.WINDOW_ID_CURRENT})
Expand Down

0 comments on commit ea5d372

Please sign in to comment.