mirror of
https://github.com/Forceu/Gokapi.git
synced 2026-01-06 00:49:33 -06:00
Display error message, if encrypted download fails due to invalid SSL #219
This commit is contained in:
@@ -154,10 +154,24 @@ if (window.opener) {
|
||||
}
|
||||
|
||||
if (navigator.serviceWorker) {
|
||||
registerWorker().then(() => {
|
||||
window.onmessage = onMessage
|
||||
messages.forEach(window.onmessage)
|
||||
})
|
||||
registerWorker()
|
||||
.then(() => {
|
||||
window.onmessage = onMessage;
|
||||
messages.forEach(window.onmessage);
|
||||
})
|
||||
// This will catch the error thrown by Service Worker registration
|
||||
.catch((err) => {
|
||||
// Check if it's an SSL error
|
||||
console.log(window.onmessage);
|
||||
console.log(window);
|
||||
if (err.name === "SecurityError" && err.message.includes("SSL certificate")) {
|
||||
console.error("Invalid SSL certificate:", err);
|
||||
window.parent.displayError("Untrusted SSL certificate - unable to download. Please contact the uploader.");
|
||||
} else {
|
||||
console.error("An error occurred during Service Worker registration:", err);
|
||||
window.parent.displayError(err.name + " - Please contact the uploader");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// FF can ping sw with fetch from a secure hidden iframe
|
||||
// shouldn't really be possible?
|
||||
|
||||
Reference in New Issue
Block a user