to the top chevron

imperfect JavaScript with flawless humanism

December 12, 2020, 1 min read, In: computer technology
Originally published on: Stack Overflow

How to check SSL cert with puppeteer?

Frustrating it is when you miss renewing your SSL cert on any of your domains. And it is a hell of a job to check the different expiry dates among sites manually. with the help of puppeteer you can do it automatically.

You can use response.securityDetails() directly on the page.goto if you need the following methods:

E.g. to check validTo():

const response = await page.goto(url)
const securityDetails = response.securityDetails()
const expiryDate = securityDetails.validTo() * 1000
console.log(new Date(expiryDate))

This method can be used in a for..of loop on a huge array of URLs.

Output:

Tuesday, January 26, 2021

The output is the Valid to value of the actual SSL cert.