rvCert = STAN_GetCERTCertificate(cert);
rvCert = STAN_GetCERTCertificateOrRelease(cert);
PK11_FindCertFromNickname(char *nickname, void *wincx) {#ifdef NSS_CLASSIC    PK11SlotInfo *slot;    int count=0;    CK_OBJECT_HANDLE *certID = PK11_FindObjectsFromNickname(nickname,&slot,				 		CKO_CERTIFICATE, &count, wincx);    CERTCertificate *cert;    if (certID == CK_INVALID_HANDLE) return NULL;    cert = PK11_MakeCertFromHandle(slot,certID[0],NULL);    PK11_FreeSlot(slot);    PORT_Free(certID);    return cert;#else    PRStatus status;    CERTCertificate *rvCert = NULL;    NSSCertificate *cert = NULL;    NSSCertificate **certs = NULL;    NSSUsage usage;    NSSToken *token;    NSSTrustDomain *defaultTD = STAN_GetDefaultTrustDomain();    PK11SlotInfo *slot = NULL;    SECStatus rv;    char *nickCopy;    char *delimit = NULL;    char *tokenName;    usage.anyUsage = PR_TRUE;    nickCopy = PORT_Strdup(nickname);    if ((delimit = PORT_Strchr(nickCopy,':')) != NULL) {	tokenName = nickCopy;	nickname = delimit + 1;	*delimit = '\0';	/* find token by name */	token = NSSTrustDomain_FindTokenByName(defaultTD, (NSSUTF8 *)tokenName);	if (token) {		slot = PK11_ReferenceSlot(token->pk11slot);	}	*delimit = ':';    } else {	slot = PK11_GetInternalKeySlot();	token = PK11Slot_GetNSSToken(slot);    }    if (token) {	nssList *certList;	nssCryptokiObject **instances;	nssPKIObjectCollection *collection;	nssTokenSearchType tokenOnly = nssTokenSearchType_TokenOnly;	if (!PK11_IsPresent(slot)) {	    goto loser;	}   	rv = pk11_AuthenticateUnfriendly(slot, PR_TRUE, wincx);	if (rv != SECSuccess) {	    goto loser;	}	collection = nssCertificateCollection_Create(defaultTD, NULL);	if (!collection) {	    goto loser;	}	certList = nssList_Create(NULL, PR_FALSE);	if (!certList) {	    nssPKIObjectCollection_Destroy(collection);	    goto loser;	}	(void)nssTrustDomain_GetCertsForNicknameFromCache(defaultTD, 	                                                  nickname, 	                                                  certList);	transfer_token_certs_to_collection(certList, token, collection);	instances = nssToken_FindCertificatesByNickname(token,	                                                NULL,	                                                nickname,	                                                tokenOnly,	                                                0,	                                                &status);	nssPKIObjectCollection_AddInstances(collection, instances, 0);	nss_ZFreeIf(instances);	/* if it wasn't found, repeat the process for email address */	if (nssPKIObjectCollection_Count(collection) == 0 &&	    PORT_Strchr(nickname, '@') != NULL) 	{	    char* lowercaseName = CERT_FixupEmailAddr(nickname);	    if (lowercaseName) {		(void)nssTrustDomain_GetCertsForEmailAddressFromCache(defaultTD, 								      lowercaseName, 								      certList);		transfer_token_certs_to_collection(certList, token, collection);		instances = nssToken_FindCertificatesByEmail(token,							     NULL,							     lowercaseName,							     tokenOnly,							     0,							     &status);		nssPKIObjectCollection_AddInstances(collection, instances, 0);		nss_ZFreeIf(instances);		PORT_Free(lowercaseName);	    }	}	certs = nssPKIObjectCollection_GetCertificates(collection, 	                                               NULL, 0, NULL);	nssPKIObjectCollection_Destroy(collection);	if (certs) {	    cert = nssCertificateArray_FindBestCertificate(certs, NULL, 	                                                   &usage, NULL);	    if (cert) {		rvCert = STAN_GetCERTCertificate(cert);	    }	    nssCertificateArray_Destroy(certs);	}	nssList_Destroy(certList);    }    if (slot) {	PK11_FreeSlot(slot);    }    if (nickCopy) PORT_Free(nickCopy);    return rvCert;loser:    if (slot) {	PK11_FreeSlot(slot);    }    if (nickCopy) PORT_Free(nickCopy);    return NULL;#endif}