Skip to content

Commit e9929cc

Browse files
committed
fix: add setCertificateVerifyProc for net.fetch self-signed cert support
The certificate-error handler only applies to webContents (renderer) requests. net.fetch in the main process needs setCertificateVerifyProc on the default session to accept self-signed certs from localhost. Registered via app.whenReady() before appMain() to ensure it's active before any health check.
1 parent f51c0c3 commit e9929cc

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

ui/desktop/src/main.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,11 @@ async function configureProxy() {
9898

9999
if (started) app.quit();
100100

101-
// Accept self-signed certificates from the local goosed server (127.0.0.1).
101+
// Accept self-signed certificates from the local goosed server.
102102
// goosed generates a fresh self-signed TLS cert on every launch so that
103103
// MCP app iframes are served over HTTPS and get a secure context.
104-
// Registered at the top level so it's active before any createChat() call.
104+
// certificate-error handles webContents requests (renderer).
105+
// setCertificateVerifyProc handles net.fetch requests (main process).
105106
app.on('certificate-error', (event, _webContents, url, _error, _certificate, callback) => {
106107
const parsed = new URL(url);
107108
if (parsed.hostname === '127.0.0.1' || parsed.hostname === 'localhost') {
@@ -112,6 +113,16 @@ app.on('certificate-error', (event, _webContents, url, _error, _certificate, cal
112113
}
113114
});
114115

116+
app.whenReady().then(() => {
117+
session.defaultSession.setCertificateVerifyProc((request, callback) => {
118+
if (request.hostname === '127.0.0.1' || request.hostname === 'localhost') {
119+
callback(0); // Accept
120+
} else {
121+
callback(-3); // Use default verification
122+
}
123+
});
124+
});
125+
115126
if (process.env.ENABLE_PLAYWRIGHT) {
116127
const debugPort = process.env.PLAYWRIGHT_DEBUG_PORT || '9222';
117128
console.log(`[Main] Enabling Playwright remote debugging on port ${debugPort}`);

0 commit comments

Comments
 (0)