diff --git a/packages/node_modules/@node-red/nodes/core/network/05-tls.js b/packages/node_modules/@node-red/nodes/core/network/05-tls.js index c1b2c2105..5a3147af6 100644 --- a/packages/node_modules/@node-red/nodes/core/network/05-tls.js +++ b/packages/node_modules/@node-red/nodes/core/network/05-tls.js @@ -22,15 +22,16 @@ module.exports = function(RED) { RED.nodes.createNode(this,n); this.valid = true; this.verifyservercert = n.verifyservercert; - var certPath = n.cert.trim(); - var keyPath = n.key.trim(); - var caPath = n.ca.trim(); - var p12Path = n.p12.trim(); + var certPath, keyPath, caPath, p12Path; + if (n.cert) { certPath = n.cert.trim(); } + if (n.key) { keyPath = n.key.trim(); } + if (n.ca) { caPath = n.ca.trim(); } + if (n.p12) { p12Path = n.p12.trim(); } this.certType = n.certType || "files"; this.servername = (n.servername||"").trim(); this.alpnprotocol = (n.alpnprotocol||"").trim(); - if ((certPath.length > 0) || (keyPath.length > 0) || (caPath.length > 0)) { + if ((certPath && certPath.length > 0) || (keyPath && keyPath.length > 0) || (caPath && caPath.length > 0)) { if ( (certPath.length > 0) !== (keyPath.length > 0)) { this.valid = false; @@ -55,7 +56,7 @@ module.exports = function(RED) { return; } } - else if (p12Path.length > 0) { + else if (p12Path && p12Path.length > 0) { try { this.pfx = fs.readFileSync(p12Path); } diff --git a/test/resources/50-file-test-file.txt b/test/resources/50-file-test-file.txt new file mode 100644 index 000000000..0491f12fe --- /dev/null +++ b/test/resources/50-file-test-file.txt @@ -0,0 +1,2 @@ +File message line 1 +File message line 2 diff --git a/test/unit/@node-red/runtime/lib/nodes/.testUserHome/.config.runtime.json b/test/unit/@node-red/runtime/lib/nodes/.testUserHome/.config.runtime.json new file mode 100644 index 000000000..7bf5a81bd --- /dev/null +++ b/test/unit/@node-red/runtime/lib/nodes/.testUserHome/.config.runtime.json @@ -0,0 +1,4 @@ +{ + "instanceId": "bff8dba3f474d406", + "_credentialSecret": "c9ca84d93a4f6236426cc740b147b50f32b3dd9aab9f4191390a604197722a4d" +} \ No newline at end of file