Node-RED HTTPS Request with Peer Certificate Output
raw JSON →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.
Common errors
error Error: unable to verify the first certificate ↓
rejectUnauthorized: false) with caution. error Node-RED: [error] [https request:myNode] TypeError: Cannot read properties of undefined (reading 'commonName') ↓
msg.peerCertificate properties, always include a check: if (msg.peerCertificate && msg.peerCertificate.commonName) { ... } in your function nodes. error Error: getaddrinfo ENOTFOUND example.com ↓
Warnings
breaking 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. ↓
gotcha 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. ↓
gotcha 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. ↓
Install
npm install node-red-contrib-https yarn add node-red-contrib-https pnpm add node-red-contrib-https Imports
- node-red-contrib-https wrong
import { httpsRequest } from 'node-red-contrib-https'correctnpm install node-red-contrib-https - HTTPS Request Node (from palette)
Drag 'HTTPS Request' from the Network section of the Node-RED palette into your flow. - msg.peerCertificate wrong
msg.payload.peerCertificatecorrectmsg.peerCertificate
Quickstart
[{"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"]]} ]