Skip to content

Commit 7a79c2f

Browse files
committed
fix(certificate): untrusted cert prompt not shown for requests
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
1 parent 6ffd24f commit 7a79c2f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/main.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
const { app, dialog, ipcMain, desktopCapturer, systemPreferences, shell, BrowserWindow } = require('electron')
6+
const { app, dialog, ipcMain, desktopCapturer, systemPreferences, shell, BrowserWindow, session } = require('electron')
77
const { spawn } = require('node:child_process')
88
const fs = require('node:fs')
99
const path = require('node:path')
@@ -230,6 +230,15 @@ app.whenReady().then(async () => {
230230
}
231231
})
232232

233+
// Allow requests to a server with accepted untrusted certificate
234+
// Note: the result of this verification is cached by domain in Electron
235+
// There is no way to clean the cache except by restarting the app
236+
session.defaultSession.setCertificateVerifyProc(async (request, callback) => {
237+
const isAccepted = await promptCertificateTrust(mainWindow, request.certificate)
238+
callback(isAccepted ? 0 : -107)
239+
})
240+
241+
// Allow web-view with accepted untrusted certificate (Login Flow)
233242
app.on('certificate-error', async (event, webContents, url, error, certificate, callback) => {
234243
event.preventDefault()
235244

0 commit comments

Comments
 (0)