本文介绍了如何使用chrome puppeteer访问ssl证书内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用chrome puppeteer访问URL的证书详细信息.可以使用当前的puppeteer API来做到这一点吗?

I would like to access certificate details of a url using chrome puppeteer. Is it possible to do it with current puppeteer API?

推荐答案

正如Grant Miller所说,您可以使用Chrome DevTools协议 Network.getCertificate 方法,而不仅仅是securityDetails伪造者响应方式.

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.

这篇关于如何使用chrome puppeteer访问ssl证书内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 21:27