From 936f024e33f08ddf58dae4291ad5a6b8f6d3cd65 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Wed, 4 Dec 2024 12:54:06 +0000 Subject: [PATCH] reverse test logic of existence of pfx --- .../@node-red/nodes/core/network/05-tls.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) 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 0c588fc66..3dd3ba8b5 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 @@ -31,7 +31,17 @@ module.exports = function(RED) { this.servername = (n.servername||"").trim(); this.alpnprotocol = (n.alpnprotocol||"").trim(); - if ((certPath && certPath.length > 0) || (keyPath && keyPath.length > 0) || (caPath && caPath.length > 0)) { + if (this.certType === "pfx" && p12Path && p12Path.length > 0) { + try { + this.pfx = fs.readFileSync(p12Path); + } + catch(err) { + this.valid = false; + this.error(err.toString()); + return; + } + } + else if ((certPath && certPath.length > 0) || (keyPath && keyPath.length > 0) || (caPath && caPath.length > 0)) { if ( (certPath && certPath.length > 0) !== (keyPath && keyPath.length > 0)) { this.valid = false; this.error(RED._("tls.error.missing-file")); @@ -55,16 +65,6 @@ module.exports = function(RED) { return; } } - else if (p12Path && p12Path.length > 0) { - try { - this.pfx = fs.readFileSync(p12Path); - } - catch(err) { - this.valid = false; - this.error(err.toString()); - return; - } - } else { if (this.credentials) { var certData = this.credentials.certdata || "";