forked from NikolaiT/scrapeulous
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcert.js
28 lines (26 loc) · 735 Bytes
/
cert.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
* @author Nikolai Tschacher
* @version 1.0
* @last_modified March 2020
* @website: incolumitas.com
*
* Returns the DER-encoded certificate of the url to be visited.
*
* Decode with a library such as:
* https://www.npmjs.com/package/asn1js
*/
class Render extends BrowserWorker {
async crawl(url) {
let cert = null;
this.page.on('response', async (res) => {
if (res.securityDetails() != null) {
let response_url = res.url();
if (response_url === url || response_url.replace(/\//g, '') == url.replace(/\//g, '')) {
cert = await this.page._client.send('Network.getCertificate', {origin: res.url()});
}
}
});
await this.page.goto(url);
return cert;
}
}