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()){
> std::cerr<< "This is a password"<< std::endl;
> nsCOMPtr<nsISupports> cert;
> NodePrincipal()->GetCertificate(getter_AddRefs(cert));
> if(cert){
> std::cerr<< "CERT"<< std::endl;
> nsCOMPtr<nsIX059Cert> c = do_QueryInterface(cert);
nsIX509Cert
> PRUint32 = 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. Maybe NodePrincipal()->GetCertificate() only gets you a cert if
the page itself is signed.... Come to think of it, almost certainly
true. :(
Maybe what would work better is something like this:
if(IsPasswordTextControl()){
nsIChannel* chan = OwnerDoc()->GetChannel();
if (chan) {
nsCOMPtr<nsISupports> securityInfo;
chan->GetSecurityInfo(getter_AddRefs(securityInfo));
nsCOMPtr<nsISSLStatusProvider> provider =
do_QueryInterface(securityInfo);
if (provider) {
nsCOMPtr<nsISSLStatus> status;
provider->GetSSLStatus(getter_AddRefs(status));
if (status) {
nsCOMPtr<nsIX509Cert> cert;
status->GetServerCert(getter_AddRefs(cert));
if (cert) {
PRUint32 length;
PRUint8* data;
cert->GetRawDER(&length,&data);
// Whatever you want
NS_Free(data);
}
}
}
}
}
-Boris