if (NSS_GetError() == NSS_ERROR_INVALID_CERTIFICATE) { PORT_SetError(SEC_ERROR_REUSED_ISSUER_AND_SERIAL); }
__CERT_AddTempCertToPerm(CERTCertificate *cert, char *nickname,		       CERTCertTrust *trust){    NSSUTF8 *stanNick;    PK11SlotInfo *slot;    NSSToken *internal;    NSSCryptoContext *context;    nssCryptokiObject *permInstance;    NSSCertificate *c = STAN_GetNSSCertificate(cert);    context = c->object.cryptoContext;    if (!context) {	return SECFailure; /* wasn't a temp cert */    }    stanNick = nssCertificate_GetNickname(c, NULL);    if (stanNick && nickname && strcmp(nickname, stanNick) != 0) {	/* take the new nickname */	cert->nickname = NULL;	stanNick = NULL;    }    if (!stanNick && nickname) {	stanNick = nssUTF8_Duplicate((NSSUTF8 *)nickname, c->object.arena);    }    /* Delete the temp instance */    nssCertificateStore_Lock(context->certStore);    nssCertificateStore_RemoveCertLOCKED(context->certStore, c);    nssCertificateStore_Unlock(context->certStore);    c->object.cryptoContext = NULL;    /* Import the perm instance onto the internal token */    slot = PK11_GetInternalKeySlot();    internal = PK11Slot_GetNSSToken(slot);    permInstance = nssToken_ImportCertificate(internal, NULL,                                              NSSCertificateType_PKIX,                                              &c->id,                                              stanNick,                                              &c->encoding,                                              &c->issuer,                                              &c->subject,                                              &c->serial,					      cert->emailAddr,                                              PR_TRUE);    PK11_FreeSlot(slot);    if (!permInstance) {	return SECFailure;    }    nssPKIObject_AddInstance(&c->object, permInstance);    nssTrustDomain_AddCertsToCache(STAN_GetDefaultTrustDomain(), &c, 1);    /* reset the CERTCertificate fields */    cert->nssCertificate = NULL;    cert = STAN_GetCERTCertificate(c); /* will return same pointer */    if (!cert) {        return SECFailure;    }    cert->istemp = PR_FALSE;    cert->isperm = PR_TRUE;    if (!trust) {	return PR_SUCCESS;    }    return (STAN_ChangeCertTrust(cert, trust) == PR_SUCCESS) ? 							SECSuccess: SECFailure;}