if (serverCert) status->mServerCert = new nsNSSCertificate(serverCert);
if (serverCert) { status->mServerCert = new nsNSSCertificate(serverCert); CERT_DestroyCertificate(serverCert); }
void PR_CALLBACK HandshakeCallback(PRFileDesc* fd, void* client_data) {  PRInt32 sslStatus;  char* signer = nsnull;  char* cipherName = nsnull;  PRInt32 keyLength;  nsresult rv;  PRInt32 encryptBits;  if (SECSuccess != SSL_SecurityStatus(fd, &sslStatus, &cipherName, &keyLength,                                       &encryptBits, &signer, nsnull)) {    return;  }  PRInt32 secStatus;  if (sslStatus == SSL_SECURITY_STATUS_OFF)    secStatus = nsIWebProgressListener::STATE_IS_BROKEN;  else if (encryptBits >= 90)    secStatus = (nsIWebProgressListener::STATE_IS_SECURE |                 nsIWebProgressListener::STATE_SECURE_HIGH);  else    secStatus = (nsIWebProgressListener::STATE_IS_SECURE |                 nsIWebProgressListener::STATE_SECURE_LOW);  CERTCertificate *peerCert = SSL_PeerCertificate(fd);  char* caName = CERT_GetOrgName(&peerCert->issuer);  CERT_DestroyCertificate(peerCert);  if (!caName) {    caName = signer;  }  // If the CA name is RSA Data Security, then change the name to the real  // name of the company i.e. VeriSign, Inc.  if (nsCRT::strcmp((const char*)caName, "RSA Data Security, Inc.") == 0) {    // In this case, caName != signer since the logic implies signer    // would be at minimal "O=RSA Data Security, Inc" because caName    // is what comes after to O=.  So we're OK just freeing this memory    // without checking to see if it's equal to signer;    NS_ASSERTION(caName != signer, "caName was equal to caName when it shouldn't be");    PR_Free(caName);    caName = PL_strdup("Verisign, Inc.");  }  nsXPIDLString shortDesc;  const PRUnichar* formatStrings[1] = { ToNewUnicode(NS_ConvertUTF8toUCS2(caName)) };  nsCOMPtr<nsINSSComponent> nssComponent(do_GetService(kNSSComponentCID, &rv));  if (NS_SUCCEEDED(rv)) {    rv = nssComponent->PIPBundleFormatStringFromName(NS_LITERAL_STRING("SignedBy").get(),                                                   formatStrings, 1,                                                   getter_Copies(shortDesc));    nsMemory::Free(NS_CONST_CAST(PRUnichar*, formatStrings[0]));    nsNSSSocketInfo* infoObject = (nsNSSSocketInfo*) fd->higher->secret;    infoObject->SetSecurityState(secStatus);    infoObject->SetShortSecurityDescription((const PRUnichar*)shortDesc);    /* Set the SSL Status information */    nsCOMPtr<nsSSLStatus> status = new nsSSLStatus();    CERTCertificate *serverCert = SSL_PeerCertificate(fd);    if (serverCert) status->mServerCert = new nsNSSCertificate(serverCert);    status->mKeyLength = keyLength;    status->mSecretKeyLength = encryptBits;    status->mCipherName.Adopt(cipherName);    infoObject->SetSSLStatus(status);  }  if (caName != signer) {    PR_Free(caName);  }  PR_Free(signer);}