start cert viewer

This commit is contained in:
idk
2020-03-05 23:25:08 -05:00
parent 8e6832cf6c
commit 8c40a01b2f
7 changed files with 159 additions and 19 deletions

View File

@@ -259,6 +259,30 @@
"message": "7657",
"description": "Port for the Router Console"
},
"isBase32": {
"message": "I2P Base32-Formatted Address",
"description": "Message for site info panel base32"
},
"isHostName": {
"message": "I2P Jump Hostname",
"description": "Message for the site info panel hostname"
},
"siteLabel": {
"message": "Address/Site Information:",
"description": "Label for i2p site info"
},
"certLabel": {
"message": "Certificate Information:",
"description": "Label for certificate info"
},
"certAbsent": {
"message": "This site is not using HTTPS. It is still verified cryptographically by I2P.",
"description": "Content for certificate info if absent"
},
"certPresent": {
"message": "This site is using HTTPS. HTTPS over I2P is experimental and requires self-signed certificates or alternate root authorites.",
"description": "Content for certificate info if present"
},
"protocolHandlerValue": {
"message": "http://127.0.0.1:7657/i2psnark/?nofilter_newURL=%s&action=Add&foo=Add+torrent",
"description": "Value for the magnet protocol handler"

View File

@@ -439,3 +439,47 @@ function handleClick() {
browser.pageAction.openPopup();
}
browser.pageAction.onClicked.addListener(handleClick);
async function certCheck(details) {
if (details.url.startsWith("https")) {
console.log("(cert) https site", details.url);
} else {
return;
}
if (!details.url.includes(".i2p")) {
return;
}
var tabs = await browser.tabs.query({ active: true });
if (tabs == null) {
return;
}
console.log("(cert) checking cert", tabs);
for (tab in tabs) {
if (details.url == tabs[tab].url) {
console.log("(cert) right tab", tabs[tab].id);
try {
let securityInfo = await browser.webRequest.getSecurityInfo(
details.requestId,
{ certificateChain: true }
);
console.log("(cert) state is complete", securityInfo);
console.log("(cert) certificates", securityInfo.certificates);
} catch (error) {
console.error(error);
}
}
}
}
// Listen for onHeaderReceived for the target page.
// Set "blocking" and "responseHeaders".
browser.webRequest.onHeadersReceived.addListener(
certCheck,
{ urls: ["<all_urls>"] },
["blocking", "responseHeaders"]
);

52
cert.js
View File

@@ -0,0 +1,52 @@
function blankContent(id) {
let infoTitle = document.getElementById(id);
if (infoTitle === null) {
console.log("content error", id);
return;
}
infoTitle.textContent = "";
}
function contentUpdateById(id, message) {
let infoTitle = document.getElementById(id);
let messageContent = chrome.i18n.getMessage(message);
if (infoTitle === null) {
console.log("content error", id, messageContent);
return;
}
infoTitle.textContent = messageContent;
}
contentUpdateById("TypeLabel", "siteLabel");
contentUpdateById("CertLabel", "certLabel");
function tabCheck(tabInfo) {
// Information Section
console.log("(cert) checking tab");
var host = tabInfo[0].url.split(".i2p")[0] + ".i2p";
if (host.length < 51) {
contentUpdateById("AddressInfo", "isHostName");
} else {
if (host.endsWith("b32.i2p")) {
contentUpdateById("AddressInfo", "isBase32");
}
}
if (host.startsWith("https")) {
contentUpdateById("AddressCertInfo", "certPresent");
console.log("(cert) initiating request to check server cert");
fetch(host).then(response => {
console.log("Updating cert information", response);
});
} else {
contentUpdateById("AddressCertInfo", "certAbsent");
blankContent("SignedLabel");
}
}
function tabError(error) {
console.log(`Error: ${error}`);
}
const gettingCurrent = browser.tabs.query({ active: true });
gettingCurrent.then(tabCheck, tabError);

View File

@@ -342,7 +342,7 @@ function i2pHost(url) {
}
function onContextGotLog(contexts) {
if (contexts !== null) {
if (contexts != null) {
for (let context of contexts) {
console.log(context);
}

View File

@@ -124,6 +124,18 @@ var handleContextProxyRequest = async function(requestDetails) {
};
return proxy;
}
if (requestDetails.originUrl == browser.runtime.getURL("security.html")) {
console.log(
"(proxy) extension security URL",
browser.runtime.getURL("security.html")
);
proxy = {
type: getScheme(),
host: getHost(),
port: getPort()
};
return proxy;
}
if (
requestDetails.cookieStoreId == "firefox-default" ||
requestDetails.cookieStoreId == "firefox-private"

View File

@@ -153,7 +153,7 @@ var contextSetup = function(requestDetails) {
browser.tabs.remove(tabId.id);
}
browser.pageAction.setPopup({
tabId: tabId[0].id,
tabId: tabId.id,
popup: "security.html"
});
browser.pageAction.show(tabId.id);

View File

@@ -20,27 +20,35 @@
</div>
<div class="panel">
<div class="address-info">
<div id="addresstype">
<span id="TypeLabel">Address Type:</span> <span id="Type"></span>
<div id="TypeInfo">
<span id="AddressInfo"></span>
<ul>
<li>
<div class="address-info">
<div id="addresstype">
<span id="TypeLabel">Address Type:</span> <span id="Type"></span>
<div id="TypeInfo">
<span id="AddressInfo"></span>
</div>
</div>
</div>
</div>
</div>
</li>
<div class="tls-info">
<div id="sitecert">
<span id="CertLabel">Certificate Information:</span> <span id="Cert"></span>
<div id="CertInfo">
<span id="AddressCertInfo"></span>
<li>
<div class="tls-info">
<div id="sitecert">
<span id="CertLabel">Certificate Information:</span> <span id="Cert"></span>
<div id="CertInfo">
<span id="AddressCertInfo"></span>
</div>
</div>
</div>
</div>
</li>
<div id="signingcert">
<span id="SignedLabel">Signed By:</span> <span id="Signed"></span>
</div>
</div>
<li>
<div id="signingcert">
<span id="SignedLabel">Signed By:</span> <span id="Signed"></span>
</div>
</li>
</ul>
</div>
</div>
<script src="cert.js"></script>