Skip to content

Instantly share code, notes, and snippets.

@be9
Last active November 5, 2018 11:38
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save be9/23101bcd95c289dcb7b0c3ae0eb49525 to your computer and use it in GitHub Desktop.
Puppeteer: accessing SSL cert data
const puppeteer = require('puppeteer');
process.on('unhandledRejection', (reason, p) => {
console.error('Unhandled Rejection at: Promise ', p, ' reason: ', reason);
process.exit(3);
});
(async () => {
let browser;
let exitCode = 0;
try {
browser = await puppeteer.launch({headless: false, devtools: true});
const page = await browser.newPage();
const client = await page.target().createCDPSession();
await client.send('Network.enable');
page.on('response', async (res) => {
if (res.securityDetails() != null) {
console.info(await page._client.send('Network.getCertificate', {origin: res.url()}));
}
});
await page.goto('https://www.chase.com/', {
waitUntil: 'networkidle2',
timeout: 3000000
});
} catch (e) {
console.error('Got exception', e);
exitCode = 1;
} finally {
if (browser != null) {
await browser.close();
}
process.exit(exitCode);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment