# Get SSL Certificate from addon

**URL:** <https://discourse.mozilla.org/t/get-ssl-certificate-from-addon/11691>\
**Category:** Development\
**Created:** [October 25, 2016, 4:05pm UTC](https://discourse.mozilla.org/t/get-ssl-certificate-from-addon/11691 "2016-10-25T16:05:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ehhc](https://avatars.discourse-cdn.com/v4/letter/e/71e660/32.png) [@ehhc](https://discourse.mozilla.org/u/ehhc)\
**Post date:** [October 25, 2016, 4:05pm UTC](https://discourse.mozilla.org/t/get-ssl-certificate-from-addon/11691/1 "2016-10-25T16:05:09Z")

</div>

Hi,  
I’m trying to develop an addon (using jpm) to show certain information about the ssl/tls certificate of the current web page.

Unfortunately I didn’t found anyway to retrieve the ssl certificate of the current tab. I found this blockpost: [https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/How\_to\_check\_the\_secruity\_state\_of\_an\_XMLHTTPRequest\_over\_SSL](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/How_to_check_the_secruity_state_of_an_XMLHTTPRequest_over_SSL) but in this solution there would be a new xmlhttprequest request for every check and i don’t think that that can be a good solution. Furthermore i would get problems when i would try to check websites with self signed certificates.

Are there any ways (i didn’t found) to ask the tab or window to return the current certificate? I noticed that a tab has the property url so i can get the current url but I didn’t found anyway to access the security information…

Do you have any ideas? Thanks in advance…  
Best regards,  
Chris

---

<div class="post-metadata">

**Author:** ![NilkasG](https://avatars.discourse-cdn.com/v4/letter/n/0ea827/32.png) [@NilkasG](https://discourse.mozilla.org/u/NilkasG)\
**Post date:** [October 25, 2016, 4:40pm UTC](https://discourse.mozilla.org/t/get-ssl-certificate-from-addon/11691/2 "2016-10-25T16:40:40Z")

</div>

I don’t think there is an SDK API for this. You will have to resort to `require('chrome')` and dig in deeper.

This is the script that is responsible for the security tab of the little page info popup:  
chrome://browser/content/pageinfo/security.js

You should find everything you need in there.

---

<div class="post-metadata">

**Author:** ![ehhc](https://avatars.discourse-cdn.com/v4/letter/e/71e660/32.png) [@ehhc](https://discourse.mozilla.org/u/ehhc)\
**Post date:** [October 26, 2016, 2:00pm UTC](https://discourse.mozilla.org/t/get-ssl-certificate-from-addon/11691/3 "2016-10-26T14:00:39Z")

</div>

Hi,  
using the link you provided i was able to figure out how to get the information about security details.  
Thanks a lot for your answer.

I used a similar approach as the security panel and query the securityUI to get the information i want to get. Unfortunately the nsISecureBrowserUI, which includes the information i want to obtain, seems not to be documentated (or i’m not able to find the correct document). The link provided in the documentation leads to this page ([https://developer.mozilla.org/en-US/docs/XPCOM\_Interface\_Reference/nsISecureBrowserUI](https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsISecureBrowserUI)) which is a 404 error page…

Anyway you helped me a lot. Thanks a lot for that. If you’re interessted in my solution you can see the code below:

> **solution**
>
> ```
> let { Cc, Ci } = require('chrome');
> let tabs = require("sdk/tabs");
> let tab_utils = require("sdk/tabs/utils");
> let { modelFor } = require("sdk/model/core");
> let { viewFor } = require("sdk/view/core");
> 
> function mapHighLevelToLowLevel(tab) {
> var lowLevelTab = viewFor(tab);
> var browser = tab_utils.getBrowserForTab(lowLevelTab);
> getSecInfo(browser.securityUI);
> }
> 
> function getSecInfo(ui){
> if (!ui)
> return null;
> 
> var status = ui.SSLStatus;
> if(status != null && status != undefined){
> console.log(status.serverCert.sha256Fingerprint);
> // see chrome://browser/content/pageinfo/security.js for more possible security informations
> } else {
> console.log('status was null; no information available');
> }
> }
> 
> tabs.open("https://www.test.de");
> tabs.on("ready", mapHighLevelToLowLevel);
> 
> ```
