diff options
author | chrisk%netscape.com <devnull@localhost> | 2000-06-06 21:46:11 +0000 |
---|---|---|
committer | chrisk%netscape.com <devnull@localhost> | 2000-06-06 21:46:11 +0000 |
commit | 380bd2127fdf32196657c4ea42174ce9880994d4 (patch) | |
tree | 61622db714a9aa19c359deb3c7892ec5955bae8c | |
parent | 498e5e6a4381c3f9026e311a425cd90c86cd0fe0 (diff) | |
download | nss-hg-380bd2127fdf32196657c4ea42174ce9880994d4.tar.gz |
Add CERT_CertListFromCert function
-rw-r--r-- | security/nss/lib/certdb/cert.h | 3 | ||||
-rw-r--r-- | security/nss/lib/certhigh/certhigh.c | 32 |
2 files changed, 35 insertions, 0 deletions
diff --git a/security/nss/lib/certdb/cert.h b/security/nss/lib/certdb/cert.h index a390af7f3..c12b77489 100644 --- a/security/nss/lib/certdb/cert.h +++ b/security/nss/lib/certdb/cert.h @@ -902,6 +902,9 @@ extern CERTCertificateList * CERT_CertChainFromCert(CERTCertificate *cert, SECCertUsage usage, PRBool includeRoot); +extern CERTCertificateList * +CERT_CertListFromCert(CERTCertificate *cert); + extern void CERT_DestroyCertificateList(CERTCertificateList *list); /* is cert a newer than cert b? */ diff --git a/security/nss/lib/certhigh/certhigh.c b/security/nss/lib/certhigh/certhigh.c index c01de0b81..c75f97a6e 100644 --- a/security/nss/lib/certhigh/certhigh.c +++ b/security/nss/lib/certhigh/certhigh.c @@ -1013,6 +1013,38 @@ loser: return NULL; } +CERTCertificateList * +CERT_CertListFromCert(CERTCertificate *cert) +{ + CERTCertificateList *chain = NULL; + int rv; + PRArenaPool *arena; + + /* arena for SecCertificateList */ + arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); + if (arena == NULL) goto no_memory; + + /* build the CERTCertificateList */ + chain = (CERTCertificateList *)PORT_ArenaAlloc(arena, sizeof(CERTCertificateList)); + if (chain == NULL) goto no_memory; + chain->certs = (SECItem*)PORT_ArenaAlloc(arena, 1 * sizeof(SECItem)); + if (chain->certs == NULL) goto no_memory; + rv = SECITEM_CopyItem(arena, chain->certs, &(cert->derCert)); + if (rv < 0) goto loser; + chain->len = 1; + chain->arena = arena; + + return chain; + +no_memory: + PORT_SetError(SEC_ERROR_NO_MEMORY); +loser: + if (arena != NULL) { + PORT_FreeArena(arena, PR_FALSE); + } + return NULL; +} + void CERT_DestroyCertificateList(CERTCertificateList *list) { |