-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
25 lines (21 loc) · 864 Bytes
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function tlsCallback(details) {
browser.webRequest.getSecurityInfo(details.requestId, {}).then(results => {
var certs = results.certificates;
if (certs) {
window.certInfo = [];
certs.forEach(cert => {
console.log(cert.subject, cert.fingerprint.sha1);
window.certInfo.push({CN: parseCommonName(cert.subject), SHA1: cert.fingerprint.sha1});
});
}
});
}
function parseCommonName(subject) {
const CN = 'CN=';
const sep = ',';
const startIndex = subject.indexOf(CN) + CN.length;
const endIndex = subject.indexOf(sep, startIndex);
return subject.substring(startIndex, endIndex);
}
//CN=www.example.org,OU=Technology,O=Internet Corporation for Assigned Names and Numbers,L=Los Angeles,ST=California,C=US
browser.webRequest.onHeadersReceived.addListener(tlsCallback, {urls: ["https://*/"]}, ["blocking"]);