Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

Commit

Permalink
fix(electron): write dh2048.pem as u+rw
Browse files Browse the repository at this point in the history
  • Loading branch information
devinus committed Jan 28, 2019
1 parent c706604 commit b614651
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions ember-electron/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const startDaemon = async () => {
}

const tlsPath = path.join(dataPath, 'tls');
const dhParamPath = path.join(tlsPath, 'dh2048.pem');
const dhparamPath = path.join(tlsPath, 'dh2048.pem');
if (!config.rpc.secure) {
log.info('Generating secure node RPC configuration...');
const clientsPath = path.join(tlsPath, 'clients');
Expand All @@ -137,9 +137,10 @@ const startDaemon = async () => {
const serverCertPath = path.join(tlsPath, 'server.cert.pem');
const serverKeyPath = path.join(tlsPath, 'server.key.pem');
const serverPems = generateCert('nanowalletcompany.com');
const dhparam = await fs.readFileAsync(path.join(__dirname, 'tls', 'dh2048.pem'));
await writeFileAtomic(serverCertPath, normalizeNewline(serverPems.cert), { mode: 0o600 });
await writeFileAtomic(serverKeyPath, normalizeNewline(serverPems.private), { mode: 0o600 });
await cpFile(path.join(__dirname, 'tls', 'dh2048.pem'), dhParamPath);
await writeFileAtomic(dhparamPath, normalizeNewline(dhparam), { mode: 0o600 });

const clientCertPath = path.join(clientsPath, 'rpcuser1.cert.pem');
const clientKeyPath = path.join(clientsPath, 'rpcuser1.key.pem');
Expand All @@ -158,7 +159,7 @@ const startDaemon = async () => {
server_cert_path: serverCertPath,
server_key_path: serverKeyPath,
server_key_passphrase: '',
server_dh_path: dhParamPath,
server_dh_path: dhparamPath,
client_certs_path: clientsPath,
};
}
Expand Down Expand Up @@ -232,7 +233,7 @@ const startDaemon = async () => {
const { client_certs_path: clientCertsPath } = config.rpc.secure;
const cert = await fs.readFileAsync(path.join(clientCertsPath, 'rpcuser1.cert.pem'));
const key = await fs.readFileAsync(path.join(clientCertsPath, 'rpcuser1.key.pem'));
const dhparam = await fs.readFileAsync(dhParamPath);
const dhparam = await fs.readFileAsync(dhparamPath);
const proxy = httpProxy.createProxyServer({
target: {
host,
Expand Down
2 changes: 1 addition & 1 deletion ember-electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ const run = async () => {

const storeVersion = store.get('version');
if (!storeVersion || semver.gt(version, storeVersion)) {
const outdatedAssets = ['config.json', 'log'];
const outdatedAssets = ['config.json', 'log', 'tls'];
log.info('Deleting outdated assets:', outdatedAssets.join(', '));
await del(outdatedAssets, { force: true, cwd: dataPath });
}
Expand Down

0 comments on commit b614651

Please sign in to comment.