从 Firefox 中被拒绝的连接获取证书链

Getting certificate chain from rejected connections in firefox

如果我使用 browser.webRequest.getSecurityInfo inside a browser.webRequest.onHeadersReceived listener during a regular https connection, but if the connection failed due to a security issue such as an expired certificate 我就能很好地获得锁链然后 onHeadersReceived 永远不会被触发。
如果我接受错误证书,那么 onHeadersReceived 会被触发,但安全信息不包含错误证书。

我尝试查看 browser.webRequest.onErrorOccurred and browser.webRequest.onCompleted,但未能使 getSecurityInfo 在这些环境中工作

我知道浏览器本身有这个信息,因为你可以让它在内置查看器中显示证书链(可以显示 url_encode(base64_encode(DER_certificate) 格式的任意证书)

有谁知道我怎样才能获得好的证书对象或至少 DER 字节(编码与否,这无关紧要)?

If I accept the bad certificate then onHeadersReceived does get triggered, but the security info does not contain the bad certificate.

这是 Firefox 中的 bug

I tried looking at browser.webRequest.onErrorOccurred and browser.webRequest.onCompleted but had no luck in getting getSecurityInfo to work in those contexts

如文档所述:getSecurityInfo 仅适用于 onHeadersReceived。有两个相关的错误,1499592 and 1474657,使 getSecurityInfo 也可以与其他侦听器一起工作。