Node-RED node to retrieve SSL certificate information from a web server
npm install node-red-contrib-ssl-certificatemsg.server on the incoming message.
msg.port.
msg.payload for
msg.valid_from and msg.valid_to.
json
[{"id":"2b30354f.61e9ba","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"97e9dc85.9d1978","type":"http request","z":"2b30354f.61e9ba","name":"Discord webhook","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://discordapp.com/api/webhooks/...","tls":"","persist":false,"proxy":"","authType":"","x":950,"y":60,"wires":[[]]},{"id":"6c9041fb.a85fc8","type":"function","z":"2b30354f.61e9ba","name":"prepare discord","func":"let text;\n\nif (msg.payload == \"expired\") {\n text = \"The certificate of \" + msg.server + \" has expired!\";\n color = 16711680;\n} else if (msg.payload == \"expires_soon\") {\n text = \"The certificate of \" + msg.server + \" will expire soon, check renew.\";\n color = 16776960;\n} else {\n return;\n}\n\nreturn {\n payload: {\n embeds: [{\n title: text,\n color: color\n }]\n }\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":740,"y":60,"wires":[["97e9dc85.9d1978"]]},{"id":"168411f5.7aef96","type":"function","z":"2b30354f.61e9ba","name":"Check date validity","func":"const days = 14 24 60 60 1000;\nconst now = new Date().getTime();\n\nconst valid_from = msg.valid_from.getTime();\nconst valid_to = msg.valid_to.getTime();\n\nif (now > valid_to) {\n msg.payload = \"expired\";\n} else if (now + days > valid_to) {\n msg.payload = \"expires_soon\";\n} else if (now < valid_from) {\n msg.payload = \"not_yet_valid\";\n} else {\n msg.payload = \"valid\";\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":530,"y":60,"wires":[["6c9041fb.a85fc8"]]},{"id":"b4ab6e8d.61d578","type":"ssl-certificate","z":"2b30354f.61e9ba","name":"","server":"example.com","x":320,"y":60,"wires":[["168411f5.7aef96"]]},{"id":"ad0cf6d8.711538","type":"cronplus","z":"2b30354f.61e9ba","name":"daily@noon","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"daily","topic":"daily","payloadType":"default","payload":"","expressionType":"cron","expression":"0 0 12 *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":130,"y":60,"wires":[["b4ab6e8d.61d578"]]}]
``