Search code examples
javascriptnode-red

Error: unable to verify the first certificate in Node-Red


I am trying to call RESTful service (out side of my domain) in a simple Node-Red flow.

The flow is illustrated in the following diagram: enter image description here

The function for calling the service:

var data = {};
data[“someparameter”] = “somevalue”;
msg.method = "POST";
msg.headers = { "Content-Type": "application/json" };
msg.payload = JSON.stringify(data);
msg.url = "https://myserviceip/myendpoint/mymethod”;
return msg;

Nonetheless i get the following error:

"Error: unable to verify the first certificate : https://myserviceip/myendpoint/mymethod"

Setting the msg.rejectUnauthorized in the header to false did not work.

msg.rejectUnauthorized = false;  // to avoid the error but it does not work

Solution

  • Having had a look at the http-request node I don't think it's possible at the moment based on a flag in the incoming message, but it can be done in the node editor. Double click on the http-request node, then tick the "Enable secure (SSL/TLS) connection" checkbox. Next create a new TLS Config and then uncheck the "Verify server certificate" checkbox.

    Save all that and it should work

    But having said that I don't think it would be that hard to update the http-request node to support the msg.rejectUnauthorized. I'll look at sticking a pull request in (https://github.com/node-red/node-red/pull/1207).