Last active
November 5, 2018 11:38
-
-
Save be9/23101bcd95c289dcb7b0c3ae0eb49525 to your computer and use it in GitHub Desktop.
Puppeteer: accessing SSL cert data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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