I would like to access certificate details of a url using chrome puppeteer. Is it possible to do it with current puppeteer API?
To check an SSL certificate on any website, all you need to do is follow two simple steps. First, check if the URL of the website begins with HTTPS, where S indicates it has an SSL certificate. Second, click on the padlock icon on the address bar to check all the detailed information related to the certificate.
First, go to any SSL-enabled website and tap on the padlock icon next to the URL. Now tap on the “Details” link. A popup will be on your screen that includes CA information along with security protocol and hashing algorithm used. Tap on Certificate Information to view more details about the certificate.
You can access the DER-encoded certificate using the Chrome DevTools Protocol Network.getCertificate
method:
const certificate = await page._client.send('Network.getCertificate', {
origin: 'https://example.com/',
});
for (let i = 0; i < certificate.tableNames.length; i++) {
console.log(certificate.tableNames[i]);
}
As Grant Miller said, you can access the full DER-encoded certificate using the Chrome DevTools Protocol Network.getCertificate
method, instead of just the securityDetails a puppeteer response provices.
page.on('response', async (res) => {
if (res.securityDetails() != null) {
console.info(await page._client.send('Network.getCertificate', {origin: res.url()}));
/*
{ tableNames: [ 'MIIDwTCCAqmgAwIBAgIJALzkRqUOhsraM...' ] }
Network.getCertificate - Returns the DER-encoded certificate
*/
}
}
You can then use any node package to parse each certificate from the encoded certificate chain.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With