Flic Home

    Community

    • Login
    • Search
    • Popular
    • Users

    TlsFailure - Latenode Webhook

    Developers
    2
    4
    359
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • dhtbrowne
      dhtbrowne last edited by dhtbrowne

      Hey team,

      I use an automation platform called Latenode. It's basically like Zapier but heaps cheaper...

      I'm playing around with the hub SDK atm. I keep getting a TlsFailure error when sending the request to the Latenode webhook URL though. The SSL cert seems to be all legit on the Latenode end.
      d4000b30-10c7-4ab5-995a-2eaebbe45686-image.png

      This is the webhook URL:
      https://webhook.latenode.com/9786/dev/276ef231-6ae4-40f0-8643-e65aed2b29bb

      (I'll change it when I make the integration live so if that link is dead in a month or so and someone looks at it, it probs wont work).

      Any ideas? I've tried adding rejectUnauthorized: false into the request, but that hasn't worked.

      And this is my code:

      var buttonManager = require("buttons");
      var http = require("http");
      var url = "https://webhook.latenode.com/9786/dev/276ef231-6ae4-40f0-8643-e65aed2b29bb";
      
      function makeRequest(url, button, clickType) {
          var fullUrl = url + `?button_name=${encodeURIComponent(button.name)}&click_type=${encodeURIComponent(clickType)}&battery_status=${encodeURIComponent(button.batteryStatus)}`;
          
          http.makeRequest({
              url: fullUrl,
              method: "GET",
              headers: {"Content-Type": "application/json"}
          }, function(err, res) {
              if (err) {
                  console.log("Request error: " + err);
              } else if (res) {
                  console.log("Request status: " + res.statusCode);
                  if (res.statusCode === 308 && res.headers["Location"]) {
                      // Follow the redirect
                      console.log("Following redirect to: " + res.headers["Location"]);
                      makeRequest(res.headers["Location"], button, clickType);
                  }
              } else {
                  console.log("Response is undefined");
              }
          });
      }
      
      buttonManager.on("buttonSingleOrDoubleClickOrHold", function(obj) {
          var button = buttonManager.getButton(obj.bdaddr);
          var clickType = obj.isSingleClick ? "click" : obj.isDoubleClick ? "double_click" : "hold";
          
          makeRequest(url, button, clickType);
      });
      
      console.log("Started");
      
      Emil 1 Reply Last reply Reply Quote 0
      • Emil
        Emil FlicTeam @dhtbrowne last edited by

        @dhtbrowne I just tried. Seems to work fine now.

        1 Reply Last reply Reply Quote 0
        • dhtbrowne
          dhtbrowne @Emil last edited by

          @Emil Amazing thank you. I have reached out to them and they say they have fixed it now
          https://community.latenode.com/t/flic-webhook-integration/322

          Will do some tests in the morning when I have the hub in front of me.

          Thanks for your help

          Emil 1 Reply Last reply Reply Quote 0
          • Emil
            Emil FlicTeam @dhtbrowne last edited by

            @dhtbrowne The server sends an invalid certificate chain according to https://datatracker.ietf.org/doc/html/rfc5246 7.4.2 Certificate certificate_list:

            This is a sequence (chain) of certificates. The sender's certificate MUST come first in the list. Each following certificate MUST directly certify the one preceding it.

            This is a trace when connecting to that server:
            f80466db-03b8-418c-8b5e-78776e68e1ab-image.png
            As you can see, the second certificate is incorrectly duplicated so hence the last one does not certify the one preceeding it.

            If you go to https://www.digicert.com/help/ you can also see that the server is incorrectly configured (second certificate is duplicated):
            48706b83-1cd6-40ca-99f1-ec0173f5aeaa-image.png

            I suggest you to reach out to the website owner to fix the problem.

            dhtbrowne 1 Reply Last reply Reply Quote 0
            • First post
              Last post