зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1566797 - Handles more than one cert received in the URL (about:certificate).r=keeler
Differential Revision: https://phabricator.services.mozilla.com/D38388 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
b2cd117111
Коммит
4029445ae2
|
@ -13,12 +13,13 @@ let gElements = {};
|
|||
document.addEventListener("DOMContentLoaded", async e => {
|
||||
gElements.certificateSection = document.querySelector("certificate-section");
|
||||
let url = new URL(document.URL);
|
||||
let certInfo = url.searchParams.get("cert");
|
||||
if (!certInfo) {
|
||||
let certInfo = url.searchParams.getAll("cert");
|
||||
if (certInfo.length === 0) {
|
||||
await render(true);
|
||||
return;
|
||||
}
|
||||
await buildChain(decodeURIComponent(certInfo));
|
||||
certInfo = certInfo.map(cert => decodeURIComponent(cert));
|
||||
await buildChain(certInfo);
|
||||
});
|
||||
|
||||
export const updateSelectedItem = (() => {
|
||||
|
@ -42,26 +43,31 @@ const render = async error => {
|
|||
return Promise.resolve();
|
||||
};
|
||||
|
||||
const buildChain = async certBase64 => {
|
||||
let certDER;
|
||||
try {
|
||||
certDER = pemToDER(certBase64);
|
||||
} catch (err) {
|
||||
await render(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (certDER == null) {
|
||||
await render(true);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await parse(certDER);
|
||||
} catch (err) {
|
||||
await render(true);
|
||||
return;
|
||||
}
|
||||
|
||||
await render(false);
|
||||
const buildChain = async chain => {
|
||||
await Promise.all(
|
||||
chain
|
||||
.map(cert => {
|
||||
try {
|
||||
return pemToDER(cert);
|
||||
} catch (err) {
|
||||
return Promise.reject(err);
|
||||
}
|
||||
})
|
||||
.map(cert => {
|
||||
try {
|
||||
return parse(cert);
|
||||
} catch (err) {
|
||||
return Promise.reject(err);
|
||||
}
|
||||
})
|
||||
)
|
||||
.then(certs => {
|
||||
if (certs.length === 0) {
|
||||
return Promise.reject();
|
||||
}
|
||||
return render(false);
|
||||
})
|
||||
.catch(err => {
|
||||
render(true);
|
||||
});
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче