Re: Clarification on nsHTMLInputElement/ certificates

Boris Zbarsky <[email protected]> Wed, 18 Apr 2012 10:59:23 -0400
Newsgroups gmane.comp.mozilla.devel.dom
Message-ID <[email protected]>
On 4/18/12 9:23 AM, Anderson Walls wrote:
> // start of my addition
> if( IsPasswordTextControl() ){
>    std::cerr<<  "Entered Password Field"<<  std::endl;
> }
>
> // continue mozilla source
>
> So I now know when ever I have clicked into a password field which is
> great but I have been trying for the last few weeks to sift through
> the DOM in order to find where I can grab the certificate or determine
> that there is not one for the document/tab/frame that the user is
> currently in

Getting a representation of the certificate for the "tab" is a bit of work.

Getting it for the document the <input> is in goes like this:

   nsCOMPtr<nsISupports> cert;
   NodePrincipal()->GetCertificate(getter_AddRefs(cert));
   if (cert) {
     // Can now QI cert to nsIX509Cert, nsIX509Cert2, nsIX509Cert3,
     // extract whatever you want.
   }

-Boris