From 60d0900ca39c6cfbf10d73a2784abe2450f2647f Mon Sep 17 00:00:00 2001 From: "relyea%netscape.com" Date: Fri, 22 Sep 2000 17:34:29 +0000 Subject: [PATCH] Add NSS_NoDB_Init() --- security/nss/lib/nss/nss.h | 7 +++++- security/nss/lib/nss/nssinit.c | 40 +++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/security/nss/lib/nss/nss.h b/security/nss/lib/nss/nss.h index 79d675e1573..15df46fb3fc 100644 --- a/security/nss/lib/nss/nss.h +++ b/security/nss/lib/nss/nss.h @@ -32,7 +32,7 @@ * may use your version of this file under either the MPL or the * GPL. * - * $Id: nss.h,v 1.1 2000-03-31 20:01:55 relyea%netscape.com Exp $ + * $Id: nss.h,v 1.2 2000-09-22 17:34:28 relyea%netscape.com Exp $ */ #ifndef __nss_h_ @@ -49,6 +49,11 @@ SEC_BEGIN_PROTOS */ extern SECStatus NSS_Init(const char *configdir); +/* + * initialize NSS without a creating cert db's, key db's, or secmod db's. + */ +SECStatus NSS_NoDB_Init(const char *configdir); + /* * Close the Cert, Key databases. */ diff --git a/security/nss/lib/nss/nssinit.c b/security/nss/lib/nss/nssinit.c index 98d958549e7..ab46e6ef45f 100644 --- a/security/nss/lib/nss/nssinit.c +++ b/security/nss/lib/nss/nssinit.c @@ -32,7 +32,7 @@ * may use your version of this file under either the MPL or the * GPL. * - # $Id: nssinit.c,v 1.1 2000-03-31 20:02:17 relyea%netscape.com Exp $ + # $Id: nssinit.c,v 1.2 2000-09-22 17:34:29 relyea%netscape.com Exp $ */ #include "seccomon.h" @@ -43,6 +43,7 @@ #include "ssl.h" #include "sslproto.h" #include "secmod.h" +#include "secmodi.h" #include "nss.h" #include "secrng.h" #include "cdbhdl.h" /* ??? */ @@ -180,6 +181,42 @@ loser: return rv; } +/* + * initialize NSS without a creating cert db's, key db's, or secmod db's. + */ +SECStatus +NSS_NoDB_Init(const char * configdir) +{ + + CERTCertDBHandle certhandle = { 0 }; + SECStatus rv = SECSuccess; + SECMODModule *module; + + /* now we want to verify the signature */ + /* Initialize the cert code */ + rv = CERT_OpenVolatileCertDB(&certhandle); + if (rv != SECSuccess) { + return rv; + } + CERT_SetDefaultCertDB(&certhandle); + + RNG_RNGInit(); + RNG_SystemInfoForRNG(); + PK11_InitSlotLists(); + + module = SECMOD_NewInternal(); + if (module == NULL) { + return SECFailure; + } + rv = SECMOD_LoadModule(module); + if (rv != SECSuccess) { + return rv; + } + + SECMOD_SetInternalModule(module); + return rv; +} + void NSS_Shutdown(void) { @@ -199,3 +236,4 @@ NSS_Shutdown(void) * but there's no secmod function to close the DB. */ } +