Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node.js - how to check/get ssl certificate expiry date

I have the Let's encrypt certificate bundle. It includes the private key and certificate.crt

Using node.js and node-forge (not openssl), how can I get the expiry date of the certificate.crt?

like image 694
LAX_DEV Avatar asked Jun 26 '19 10:06

LAX_DEV


People also ask

How do I check the expiration date of an SSL certificate?

check SSL certificate expiration date from a certificate file Openssl command is a very powerful command to check certificate info in Linux.We can use the flowing command to check the expiration date. openssl x509 -enddate -noout -in file.cer

How to check the expiration date of a certificate in Linux?

Openssl command is a very powerful command to check certificate info in Linux.We can use the flowing command to check the expiration date. openssl x509 -enddate -noout -in file.cer

How to check if a website has an SSL certificate?

Linux users can easily check an SSL certificate from the Linux command-line, using the openssl utility, that can connect to a remote website over HTTPS, decode an SSL certificate and retrieve the all required data.

How can I monitor the expiry of TLS certificates?

You can receive reminders by email or through Slack. The service is free for monitoring up to 2 domains and has a cost of $ 29 per year for up to 30 domains. Certificate Expiry Monitor is an open-source utility that exposes the expiry date of TLS certificates as Prometheus metrics for those who prefer to build their own tools.


1 Answers

You can use x509 module

var crt_pem = "<certificate in pem format which is content of your certificate.crt>";
const x509 = require('x509');
var crt_obj = x509.parseCert(crt_pem);
console.log(crt_obj.notBefore);
console.log(crt_obj.notAfter);
like image 178
Bao HQ Avatar answered Sep 27 '22 23:09

Bao HQ