{"id":18046,"library":"node-red-contrib-https","title":"Node-RED HTTPS Request with Peer Certificate Output","description":"This Node-RED contribution provides an enhanced HTTP Request node specifically designed for making HTTPS requests. It extends the core Node-RED HTTP Request node by adding the `msg.peerCertificate` property to the output message, allowing flow developers to inspect the server's TLS/SSL certificate after a successful connection. This is crucial for applications requiring advanced certificate validation or logging. The package is currently at version 2.0.0, indicating a stable release with potential breaking changes from previous major versions. Node-RED contrib packages typically follow an as-needed release cadence, driven by user feedback and Node-RED core updates. Its key differentiator is the direct exposure of the `peerCertificate` object, which is not available in the standard Node-RED HTTP Request node, making it indispensable for secure or compliance-driven integrations.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","https","node-red","certificates","peerCertificates"],"install":[{"cmd":"npm install node-red-contrib-https","lang":"bash","label":"npm"},{"cmd":"yarn add node-red-contrib-https","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-red-contrib-https","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This is a Node-RED contribution package and requires a Node-RED instance to function.","package":"node-red","optional":false}],"imports":[{"note":"Node-RED nodes are installed via npm into the Node-RED environment, not imported into user JavaScript code. The node then appears in the Node-RED editor palette.","wrong":"import { httpsRequest } from 'node-red-contrib-https'","symbol":"node-red-contrib-https","correct":"npm install node-red-contrib-https"},{"note":"After installation, the node becomes available in the Node-RED editor's sidebar palette. Its visual representation is typically similar to the standard HTTP Request node.","symbol":"HTTPS Request Node (from palette)","correct":"Drag 'HTTPS Request' from the Network section of the Node-RED palette into your flow."},{"note":"The `peerCertificate` object is directly added to the root of the `msg` object by this node, not nested within `msg.payload`.","wrong":"msg.payload.peerCertificate","symbol":"msg.peerCertificate","correct":"msg.peerCertificate"}],"quickstart":{"code":"[{\"id\":\"b9e4a3c1.9c6f98\",\"type\":\"tab\",\"label\":\"HTTPS Request with Peer Certificate\",\"disabled\":false,\"info\":\"\"},{\"id\":\"e3f0d2b7.4a1e5c\",\"type\":\"https request\",\"z\":\"b9e4a3c1.9c6f98\",\"name\":\"Fetch example.com cert\",\"method\":\"GET\",\"ret\":\"obj\",\"paytoqs\":\"qs\",\"url\":\"https://example.com/\",\"tls\":\"\",\"persist\":false,\"proxy\":\"\",\"authType\":\"\",\"senderr\":false,\"x\":390,\"y\":100,\"wires\":[[\"c1d0a2f5.e3b4d6\"]]},{\"id\":\"c1d0a2f5.e3b4d6\",\"type\":\"debug\",\"z\":\"b9e4a3c1.9c6f98\",\"name\":\"Show Peer Certificate\",\"active\":true,\"tosidebar\":true,\"console\":false,\"tostatus\":false,\"complete\":\"peerCertificate\",\"targetType\":\"msg\",\"statusVal\":\"\",\"statusType\":\"auto\",\"x\":620,\"y\":100,\"wires\":[]},{\"id\":\"a7b8c9d0.e1f2a3\",\"type\":\"inject\",\"z\":\"b9e4a3c1.9c6f98\",\"name\":\"Trigger Request\",\"props\":[{\"p\":\"payload\"},{\"p\":\"topic\",\"vt\":\"str\"}],\"repeat\":\"\",\"crontab\":\"\",\"once\":false,\"onceDelay\":0.1,\"topic\":\"\",\"payload\":\"\",\"payloadType\":\"date\",\"x\":170,\"y\":100,\"wires\":[[\"e3f0d2b7.4a1e5c\"]]} ]","lang":"json","description":"This Node-RED flow demonstrates how to use the 'HTTPS Request' node to fetch data from `example.com` and then display the `peerCertificate` object in the debug sidebar."},"warnings":[{"fix":"Review the node's configuration options and ensure backward compatibility for `msg.peerCertificate` structure, especially if parsing specific certificate fields.","message":"Upgrading to version 2.0.0 might introduce configuration changes or subtle behavior differences compared to 1.x versions. Always test flows in a non-production environment after upgrading.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Ensure that your Node.js environment trusts the certificate authority for the target server. For self-signed certificates in development, consider setting `rejectUnauthorized` to `false` (with caution) or providing a custom CA certificate.","message":"Incorrectly configured TLS options (e.g., self-signed certificates, invalid CAs, or `rejectUnauthorized` set to `true` without proper CA trust) will lead to connection errors, preventing any `peerCertificate` output.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always check for the existence of `msg.peerCertificate` before attempting to access its properties (e.g., `if (msg.peerCertificate) { ... }`) and handle error paths in your flow.","message":"The `peerCertificate` property is only present on the `msg` object if the HTTPS connection is successfully established. If the connection fails due to network issues, certificate validation, or other errors, `msg.peerCertificate` will be undefined.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"In the node's TLS configuration, provide the correct CA certificate, or for development purposes, check 'Allow insecure TLS (self-signed, etc.)' (sets `rejectUnauthorized: false`) with caution.","cause":"The server's certificate chain could not be validated against the known trusted root certificates on the Node.js system. Often happens with self-signed certificates or corporate proxies.","error":"Error: unable to verify the first certificate"},{"fix":"Before accessing `msg.peerCertificate` properties, always include a check: `if (msg.peerCertificate && msg.peerCertificate.commonName) { ... }` in your function nodes.","cause":"Attempting to access a property of `msg.peerCertificate` (like `commonName`) when `msg.peerCertificate` itself is `undefined` because the HTTPS connection failed or no certificate was presented.","error":"Node-RED: [error] [https request:myNode] TypeError: Cannot read properties of undefined (reading 'commonName')"},{"fix":"Verify the URL and hostname are correctly spelled and accessible from the Node-RED instance's network. Check DNS settings if needed.","cause":"The hostname specified in the URL could not be resolved to an IP address, indicating a DNS issue or incorrect hostname.","error":"Error: getaddrinfo ENOTFOUND example.com"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}