Re: Clarification on nsHTMLInputElement/ certificates
Anderson Walls <[email protected]> Mon, 23 Apr 2012 19:11:24 -0700 (PDT)
| Newsgroups | gmane.comp.mozilla.devel.dom |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <[email protected]> |
On Apr 23, 1:08=A0pm, Boris Zbarsky <[email protected]> wrote: > On 4/23/12 10:45 AM, Anderson Walls wrote: > > > Boris you wouldn't happen to be able to direct me to the correct > > header files in order to get this all to work properly would you? > > Just nsIX509Cert.h should be enough > > > if(IsPasswordTextControl()){ > > =A0 =A0std::cerr<< =A0"This is a password"<< =A0std::endl; > > =A0 =A0nsCOMPtr<nsISupports> =A0cert; > > =A0 =A0NodePrincipal()->GetCertificate(getter_AddRefs(cert)); > > =A0 =A0if(cert){ > > =A0 =A0 =A0std::cerr<< =A0"CERT"<< =A0std::endl; > > =A0 =A0 =A0nsCOMPtr<nsIX059Cert> =A0c =3D do_QueryInterface(cert); > > nsIX509Cert > > > =A0 =A0 =A0PRUint32 =3D length; > > PRUint32 length; > > Are you sure this compiled? > > > if I try to take out the if part and just let it run I segfault when I > > go into a password field, which obviously is bad. The site I have been > > testing on is Navy Federal's web page so I know they do have a cert. > > Hmm. =A0Maybe NodePrincipal()->GetCertificate() only gets you a cert if > the page itself is signed.... =A0Come to think of it, almost certainly > true. =A0:( > > Maybe what would work better is something like this: > > =A0 =A0if(IsPasswordTextControl()){ > =A0 =A0 =A0nsIChannel* chan =3D OwnerDoc()->GetChannel(); > =A0 =A0 =A0if (chan) { > =A0 =A0 =A0 =A0nsCOMPtr<nsISupports> securityInfo; > =A0 =A0 =A0 =A0chan->GetSecurityInfo(getter_AddRefs(securityInfo)); > =A0 =A0 =A0 =A0nsCOMPtr<nsISSLStatusProvider> provider =3D > do_QueryInterface(securityInfo); > =A0 =A0 =A0 =A0if (provider) { > =A0 =A0 =A0 =A0 =A0nsCOMPtr<nsISSLStatus> status; > =A0 =A0 =A0 =A0 =A0provider->GetSSLStatus(getter_AddRefs(status)); > =A0 =A0 =A0 =A0 =A0if (status) { > =A0 =A0 =A0 =A0 =A0 =A0nsCOMPtr<nsIX509Cert> cert; > =A0 =A0 =A0 =A0 =A0 =A0status->GetServerCert(getter_AddRefs(cert)); > =A0 =A0 =A0 =A0 =A0 =A0if (cert) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0PRUint32 length; > =A0 =A0 =A0 =A0 =A0 =A0 =A0PRUint8* data; > =A0 =A0 =A0 =A0 =A0 =A0 =A0cert->GetRawDER(&length,&data); > =A0 =A0 =A0 =A0 =A0 =A0 =A0// Whatever you want > =A0 =A0 =A0 =A0 =A0 =A0 =A0NS_Free(data); > =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0} > =A0 =A0 =A0} > =A0 =A0} > > -Boris Well Boris looks like that did it. It was compiling correctly before, I just typo-ed in a '=3D', I would pray that g++ would not allow that. I now have raw DER's going to a file so this last part of my project is complete! Now just have to do a little gluing together and I should be just fine. Thank you for your continued help, I really appreciate it. I would have spend weeks looking through Mozilla's DOM before I came to a solution close to this. Have a good one sir, Go Navy. - Anderson USNA '13