reverse test logic of existence of pfx

This commit is contained in:
Dave Conway-Jones 2024-12-04 12:54:06 +00:00
parent fbf2c7b570
commit 936f024e33
No known key found for this signature in database
GPG Key ID: 1DDB0E91A28C2643

View File

@ -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 || "";