Added agent connection cert checking.
Ylian Saint-Hilaire committed
Nov 15, 2020 at 00:32 UTC
0194292e848175584b22c4545edf3c6af9774730
2 files changed
+8
-10
meshuser.js
-3
@@ -1331,13 +1331,10 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
1331
1332
// Add server TLS cert hash
1333
var tlsCertHash = null;
1334
- // TODO: Once new mesh agents seem to work, re-enable this.
1335
- /*
1334
if (parent.parent.args.ignoreagenthashcheck !== true) {
1335
tlsCertHash = parent.webCertificateFullHashs[domain.id];
1336
if (tlsCertHash != null) { command.servertlshash = Buffer.from(tlsCertHash, 'binary').toString('hex'); }
1337
}
1340
- */
1338
1339
// Add user consent messages
1340
command.soptions = {};
webserver.js
+8
-7
@@ -3218,13 +3218,10 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
3218
3219
// Instruct one of more agents to download a URL to a given local drive location.
3220
var tlsCertHash = null;
3221
- // TODO: Once new mesh agents seem to work, re-enable this.
3222
- /*
3221
if (parent.args.ignoreagenthashcheck !== true) {
3222
tlsCertHash = obj.webCertificateFullHashs[cmd.domain.id];
3223
if (tlsCertHash != null) { tlsCertHash = Buffer.from(tlsCertHash, 'binary').toString('hex'); }
3224
}
3227
- */
3225
for (var i in cmd.nodeids) {
3226
obj.GetNodeWithRights(cmd.domain, cmd.user, cmd.nodeids[i], function (node, rights, visible) {
3227
if ((node == null) || ((rights & 8) == 0) || (visible == false)) return; // We don't have remote control rights to this device
@@ -3238,10 +3235,14 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
3235
3236
// Send the agent commands to perform the batch upload operation
3237
for (var f in cmd.files) {
3241
- const acmd = { action: 'wget', overwrite: cmd.overwrite, createFolder: cmd.createFolder, urlpath: '/agentdownload.ashx?c=' + obj.parent.encodeCookie({ a: 'tmpdl', d: cmd.domain.id, nid: node._id, f: cmd.files[f].target }, obj.parent.loginCookieEncryptionKey), path: obj.path.join(agentPath, cmd.files[f].name), folder: agentPath, servertlshash: tlsCertHash };
3242
- var agent = obj.wsagents[node._id];
3243
- if (agent != null) { try { agent.send(JSON.stringify(acmd)); } catch (ex) { } }
3244
- // TODO: Add support for peer servers.
3238
+ if ((agentPath != null) && (cmd.files[f].name != null) {
3239
+ try {
3240
+ const acmd = { action: 'wget', overwrite: cmd.overwrite, createFolder: cmd.createFolder, urlpath: '/agentdownload.ashx?c=' + obj.parent.encodeCookie({ a: 'tmpdl', d: cmd.domain.id, nid: node._id, f: cmd.files[f].target }, obj.parent.loginCookieEncryptionKey), path: obj.path.join(agentPath, cmd.files[f].name), folder: agentPath, servertlshash: tlsCertHash };
3241
+ var agent = obj.wsagents[node._id];
3242
+ if (agent != null) { try { agent.send(JSON.stringify(acmd)); } catch (ex) { } }
3243
+ // TODO: Add support for peer servers.
3244
+ } catch (ex) { }
3245
+ }
3246
}
3247
});
3248
}