summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrelyea%netscape.com <devnull@localhost>2002-12-10 17:14:17 +0000
committerrelyea%netscape.com <devnull@localhost>2002-12-10 17:14:17 +0000
commitdf4b5efcf2358aff81f430c3858acb18bc947c01 (patch)
treed21a8243860cd3fc4bbba78a2a6f06b10a489b04
parent1768c33a406aeeb7f50113873519655197bfdac8 (diff)
downloadnss-hg-df4b5efcf2358aff81f430c3858acb18bc947c01.tar.gz
Create profiles for all the email addresses in a certificate.
-rw-r--r--security/nss/lib/certdb/stanpcertdb.c93
1 files changed, 53 insertions, 40 deletions
diff --git a/security/nss/lib/certdb/stanpcertdb.c b/security/nss/lib/certdb/stanpcertdb.c
index cddfbc816..5fcdc7b74 100644
--- a/security/nss/lib/certdb/stanpcertdb.c
+++ b/security/nss/lib/certdb/stanpcertdb.c
@@ -201,7 +201,7 @@ __CERT_AddTempCertToPerm(CERTCertificate *cert, char *nickname,
cert->istemp = PR_FALSE;
cert->isperm = PR_TRUE;
if (!trust) {
- return PR_SUCCESS;
+ return SECSuccess;
}
return (STAN_ChangeCertTrust(cert, trust) == PR_SUCCESS) ?
SECSuccess: SECFailure;
@@ -726,21 +726,14 @@ CERT_GetDBContentVersion(CERTCertDBHandle *handle)
return 0;
}
-/*
- *
- * Manage S/MIME profiles
- *
- */
-
SECStatus
-CERT_SaveSMimeProfile(CERTCertificate *cert, SECItem *emailProfile,
- SECItem *profileTime)
+certdb_SaveSingleProfile(CERTCertificate *cert, const char *emailAddr,
+ SECItem *emailProfile, SECItem *profileTime)
{
int64 oldtime;
int64 newtime;
SECStatus rv = SECFailure;
PRBool saveit;
- char *emailAddr;
SECItem oldprof, oldproftime;
SECItem *oldProfile = NULL;
SECItem *oldProfileTime = NULL;
@@ -750,32 +743,6 @@ CERT_SaveSMimeProfile(CERTCertificate *cert, SECItem *emailProfile,
nssSMIMEProfile *stanProfile = NULL;
PRBool freeOldProfile = PR_FALSE;
- if (!cert) {
- return SECFailure;
- }
-
- if (cert->slot && !PK11_IsInternal(cert->slot)) {
- /* this cert comes from an external source, we need to add it
- to the cert db before creating an S/MIME profile */
- PK11SlotInfo* internalslot = PK11_GetInternalKeySlot();
- if (!internalslot) {
- return SECFailure;
- }
- rv = PK11_ImportCert(internalslot, cert,
- CK_INVALID_HANDLE, NULL, PR_FALSE);
-
- PK11_FreeSlot(internalslot);
- if (rv != SECSuccess ) {
- return SECFailure;
- }
- }
-
- emailAddr = cert->emailAddr;
-
- if ( emailAddr == NULL ) {
- goto loser;
- }
-
c = STAN_GetNSSCertificate(cert);
if (!c) return SECFailure;
cc = c->object.cryptoContext;
@@ -789,8 +756,8 @@ CERT_SaveSMimeProfile(CERTCertificate *cert, SECItem *emailProfile,
oldProfileTime = &oldproftime;
}
} else {
- oldProfile = PK11_FindSMimeProfile(&slot, emailAddr, &cert->derSubject,
- &oldProfileTime);
+ oldProfile = PK11_FindSMimeProfile(&slot, (char *)emailAddr,
+ &cert->derSubject, &oldProfileTime);
freeOldProfile = PR_TRUE;
}
@@ -873,8 +840,8 @@ CERT_SaveSMimeProfile(CERTCertificate *cert, SECItem *emailProfile,
rv = (nssrv == PR_SUCCESS) ? SECSuccess : SECFailure;
}
} else {
- rv = PK11_SaveSMimeProfile(slot, emailAddr, &cert->derSubject,
- emailProfile, profileTime);
+ rv = PK11_SaveSMimeProfile(slot, (char *)emailAddr,
+ &cert->derSubject, emailProfile, profileTime);
}
} else {
rv = SECSuccess;
@@ -897,6 +864,52 @@ loser:
return(rv);
}
+/*
+ *
+ * Manage S/MIME profiles
+ *
+ */
+
+SECStatus
+CERT_SaveSMimeProfile(CERTCertificate *cert, SECItem *emailProfile,
+ SECItem *profileTime)
+{
+ const char *emailAddr;
+ SECStatus rv;
+
+ if (!cert) {
+ return SECFailure;
+ }
+
+ if (cert->slot && !PK11_IsInternal(cert->slot)) {
+ /* this cert comes from an external source, we need to add it
+ to the cert db before creating an S/MIME profile */
+ PK11SlotInfo* internalslot = PK11_GetInternalKeySlot();
+ if (!internalslot) {
+ return SECFailure;
+ }
+ rv = PK11_ImportCert(internalslot, cert,
+ CK_INVALID_HANDLE, NULL, PR_FALSE);
+
+ PK11_FreeSlot(internalslot);
+ if (rv != SECSuccess ) {
+ return SECFailure;
+ }
+ }
+
+
+ for (emailAddr = CERT_GetFirstEmailAddress(cert); emailAddr != NULL;
+ emailAddr = CERT_GetNextEmailAddress(cert,emailAddr)) {
+ rv = certdb_SaveSingleProfile(cert,emailAddr,emailProfile,profileTime);
+ if (rv != SECSuccess) {
+ return SECFailure;
+ }
+ }
+ return SECSuccess;
+
+}
+
+
SECItem *
CERT_FindSMimeProfile(CERTCertificate *cert)
{