From 18afb732384b2ff3fdb2839ecaa541a2b92a0f38 Mon Sep 17 00:00:00 2001 From: Brent Shikoski Date: Fri, 8 Sep 2023 20:53:18 -0500 Subject: [PATCH] support custom cacerts in electron app --- packages/bruno-electron/src/ipc/network/index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/bruno-electron/src/ipc/network/index.js b/packages/bruno-electron/src/ipc/network/index.js index 1aa31f4a..29860758 100644 --- a/packages/bruno-electron/src/ipc/network/index.js +++ b/packages/bruno-electron/src/ipc/network/index.js @@ -154,6 +154,21 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => { rejectUnauthorized: false }); } + else { + const cacertArray = [preferences['cacert'], process.env.SSL_CERT_FILE, process.env.NODE_EXTRA_CA_CERTS]; + cacertFile = cacertArray.find(el => el); + if (cacertFile && cacertFile.length > 1) { + try { + const fs = require('fs'); + caCrt = fs.readFileSync(cacertFile) + request.httpsAgent = new https.Agent({ + ca: caCrt + }); + } catch(err) { + console.log('Error reading CA cert file:' + cacertFile, err); + } + } + } const response = await axios(request);