Skip to content

Commit 8695100

Browse files
committed
Ensure that HTTPS requests from electron.net trust our cert
1 parent e317dbb commit 8695100

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

overrides/js/prepend-electron.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,23 @@ module.exports = function reconfigureElectron(params) {
4141
}
4242
});
4343

44+
// Register a cert verifier for the default session, so that electron.net calls
45+
// can have their certificates manually verified.
46+
app.on('ready', () => {
47+
loadedModule.session.defaultSession.setCertificateVerifyProc((req, callback) => {
48+
if (
49+
req.certificate &&
50+
req.certificate.issuerCert &&
51+
req.certificate.issuerCert.data === params.newlineEncodedCertData
52+
) {
53+
callback(0); // The cert is good, I promise
54+
} else {
55+
callback(-3); // Fallback to Chromium's own opinion
56+
}
57+
});
58+
})
59+
60+
// Also handle explicitly certificate errors from Electron in the standard way
4461
app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
4562
if (
4663
certificate.issuerCert &&

0 commit comments

Comments
 (0)