return PK11_FindCertFromDERCertItem(slot, &cert->derCert, wincx);
PK11_FindCertFromDERCert(PK11SlotInfo *slot, CERTCertificate *cert,								 void *wincx){#ifdef NSS_CLASSIC    CK_OBJECT_CLASS certClass = CKO_CERTIFICATE;    CK_ATTRIBUTE theTemplate[] = {	{ CKA_VALUE, NULL, 0 },	{ CKA_CLASS, NULL, 0 }    };    /* if you change the array, change the variable below as well */    int tsize = sizeof(theTemplate)/sizeof(theTemplate[0]);    CK_OBJECT_HANDLE certh;    CK_ATTRIBUTE *attrs = theTemplate;    SECStatus rv;    PK11_SETATTRS(attrs, CKA_VALUE, cert->derCert.data, 						cert->derCert.len); attrs++;    PK11_SETATTRS(attrs, CKA_CLASS, &certClass, sizeof(certClass));    /*     * issue the find     */    if ( !PK11_IsFriendly(slot)) {	rv = PK11_Authenticate(slot, PR_TRUE, wincx);	if (rv != SECSuccess) return NULL;    }    certh = pk11_getcerthandle(slot,cert,theTemplate,tsize);    if (certh == CK_INVALID_HANDLE) {	return NULL;    }    return PK11_MakeCertFromHandle(slot, certh, NULL);#else    CERTCertificate *rvCert = NULL;    NSSCertificate *c;    NSSDER derCert;    NSSToken *tok;    NSSTrustDomain *td = STAN_GetDefaultTrustDomain();    tok = PK11Slot_GetNSSToken(slot);    NSSITEM_FROM_SECITEM(&derCert, &cert->derCert);    if (!PK11_IsFriendly(slot)) {	if (PK11_Authenticate(slot, PR_TRUE, wincx) != SECSuccess) {	    PK11_FreeSlot(slot);	    return NULL;	}    }    c = NSSTrustDomain_FindCertificateByEncodedCertificate(td, &derCert);    if (c) {	PRBool isToken = PR_FALSE;	NSSToken **tp;	NSSToken **tokens = nssPKIObject_GetTokens(&c->object, NULL);	if (tokens) {	    for (tp = tokens; *tp; tp++) {		if (*tp == tok) {		    isToken = PR_TRUE;		    break;		}	    }	    if (!isToken) {		NSSCertificate_Destroy(c);		c = NULL;	    }	    nssTokenArray_Destroy(tokens);	}    }    if (c) {	rvCert = STAN_GetCERTCertificate(c);    }    return rvCert;#endif} 