mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-04 22:13:13 +00:00
This PR helps to validate custom/self-signed certificates for servers by saving the certificate file in certificates folder in user's appData folder. We now use this certificate with the request while validating the server when adding the organization. This validation of certificate is done by the request module itself. Fixes: #126.
38 lines
750 B
JavaScript
38 lines
750 B
JavaScript
const fs = require('fs');
|
|
|
|
let app = null;
|
|
let setupCompleted = false;
|
|
if (process.type === 'renderer') {
|
|
app = require('electron').remote.app;
|
|
} else {
|
|
app = require('electron').app;
|
|
}
|
|
|
|
const zulipDir = app.getPath('userData');
|
|
const logDir = `${zulipDir}/Logs/`;
|
|
const certificatesDir = `${zulipDir}/certificates/`;
|
|
const initSetUp = () => {
|
|
// if it is the first time the app is running
|
|
// create zulip dir in userData folder to
|
|
// avoid errors
|
|
if (!setupCompleted) {
|
|
if (!fs.existsSync(zulipDir)) {
|
|
fs.mkdirSync(zulipDir);
|
|
}
|
|
|
|
if (!fs.existsSync(logDir)) {
|
|
fs.mkdirSync(logDir);
|
|
}
|
|
|
|
if (!fs.existsSync(certificatesDir)) {
|
|
fs.mkdirSync(certificatesDir);
|
|
}
|
|
|
|
setupCompleted = true;
|
|
}
|
|
};
|
|
|
|
module.exports = {
|
|
initSetUp
|
|
};
|