CERT_SerialNumberFromDERCert(&cc->derCert, &derSerial);
SECStatus secrv; secrv = CERT_SerialNumberFromDERCert(&cc->derCert, &derSerial); if (secrv == SECFailure) { nssArena_Destroy(arena); return NULL; }
STAN_GetNSSCertificate(CERTCertificate *cc){    NSSCertificate *c;    nssCryptokiInstance *instance;    nssPKIObject *pkiob;    NSSArena *arena;    c = cc->nssCertificate;    if (c) {    	return c;    }    /* i don't think this should happen.  but if it can, need to create     * NSSCertificate from CERTCertificate values here.  */    /* Yup, it can happen. */    arena = NSSArena_Create();    if (!arena) {	return NULL;    }    c = nss_ZNEW(arena, NSSCertificate);    if (!c) {	nssArena_Destroy(arena);	return NULL;    }    NSSITEM_FROM_SECITEM(&c->encoding, &cc->derCert);    c->type = NSSCertificateType_PKIX;    pkiob = nssPKIObject_Create(arena, NULL, cc->dbhandle, NULL);    if (!pkiob) {	nssArena_Destroy(arena);	return NULL;    }    c->object = *pkiob;    nssItem_Create(arena,                   &c->issuer, cc->derIssuer.len, cc->derIssuer.data);    nssItem_Create(arena,                   &c->subject, cc->derSubject.len, cc->derSubject.data);    if (PR_TRUE) {	/* CERTCertificate stores serial numbers decoded.  I need the DER	* here.  sigh.	*/	SECItem derSerial;	CERT_SerialNumberFromDERCert(&cc->derCert, &derSerial);	nssItem_Create(arena, &c->serial, derSerial.len, derSerial.data);	PORT_Free(derSerial.data);    }    if (cc->emailAddr) {        c->email = nssUTF8_Create(arena,                                  nssStringType_PrintableString,                                  (NSSUTF8 *)cc->emailAddr,                                  PORT_Strlen(cc->emailAddr));    }    if (cc->slot) {	instance = nss_ZNEW(arena, nssCryptokiInstance);	instance->token = nssToken_AddRef(PK11Slot_GetNSSToken(cc->slot));	instance->handle = cc->pkcs11ID;	instance->isTokenObject = PR_TRUE;	if (cc->nickname) {	    instance->label = nssUTF8_Create(arena,	                                     nssStringType_UTF8String,	                                     (NSSUTF8 *)cc->nickname,	                                     PORT_Strlen(cc->nickname));	}	nssPKIObject_AddInstance(&c->object, instance);    }    c->decoding = create_decoded_pkix_cert_from_nss3cert(NULL, cc);    cc->nssCertificate = c;    return c;}