Jonah
Jonah

Reputation: 365

How can I get the SSL certificate for a given URL using javascript?

I'm working on a chrome extension that needs access to the SSL certificate of the current page on the active tab (specifically, I need the public key of the certificate). It seems the certificate information for the page is not exposed in chrome's javascript API, so I'm trying to devise a way of getting the certificate information via AJAX using the URL in the current tab.

I found some useful information on Within a web browser, is it possible for JavaScript to obtain information about the HTTPS Certificate being used for the current page?, which suggests using https://github.com/digitalbazaar/forge to "make an ajax call to the server and use a callback to inspect the certificate." I would like to implement this solution, but I don't have much knowledge of the TLS protocol, and the aforelinked javascript library is a bit lacking in the documentation department.

Does this mean I need to send a hello message to the server then extract the certificate info from the response? How would I create the request using the Forge package linked above? I'm also open to some better ideas on how to get the certificate.

Upvotes: 4

Views: 1746

Answers (1)

Jonah
Jonah

Reputation: 365

From the looks of things this is not possible. The Forge library needs to create a socket for the TLS connection. And while chrome's Javascript API lets webapps create sockets, it does not let extensions do the same.

Upvotes: 1

Related Questions