mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-05 00:02:37 +00:00
Allow applications to initialize nss without necessarily initializing databases.Needed to keep old modutil semantics. Bug 66230. reviewed by wtc.
This commit is contained in:
parent
ea8de3c817
commit
9a4a2d9ddb
@ -32,7 +32,7 @@
|
||||
* may use your version of this file under either the MPL or the
|
||||
* GPL.
|
||||
*
|
||||
* $Id: nss.h,v 1.7 2001/02/08 01:22:01 wtc%netscape.com Exp $
|
||||
* $Id: nss.h,v 1.8 2001/02/09 01:34:12 relyea%netscape.com Exp $
|
||||
*/
|
||||
|
||||
#ifndef __nss_h_
|
||||
@ -98,7 +98,7 @@ extern SECStatus NSS_InitReadWrite(const char *configdir);
|
||||
*/
|
||||
extern SECStatus NSS_Initialize(const char *configdir,
|
||||
const char *certPrefix, const char *keyPrefix, const char *secmodName,
|
||||
PRBool readOnly);
|
||||
PRBool readOnly, PRBool noCertDB, PRBool noModDB, PRBool forceOpen);
|
||||
|
||||
/*
|
||||
* initialize NSS without a creating cert db's, key db's, or secmod db's.
|
||||
|
@ -32,7 +32,7 @@
|
||||
* may use your version of this file under either the MPL or the
|
||||
* GPL.
|
||||
*
|
||||
# $Id: nssinit.c,v 1.14 2001/02/08 23:43:00 javi%netscape.com Exp $
|
||||
# $Id: nssinit.c,v 1.15 2001/02/09 01:34:12 relyea%netscape.com Exp $
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
@ -98,6 +98,9 @@ nss_keydb_name_cb(void *arg, int dbVersion)
|
||||
case 3:
|
||||
dbver = "3";
|
||||
break;
|
||||
case 1:
|
||||
dbver = "1";
|
||||
break;
|
||||
case 2:
|
||||
default:
|
||||
dbver = "";
|
||||
@ -209,8 +212,27 @@ nss_OpenVolatileSecModDB() {
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
* OK there are now lots of options here, lets go through them all:
|
||||
*
|
||||
* configdir - base directory where all the cert, key, and module datbases live.
|
||||
* certPrefix - prefix added to the beginning of the cert database example: "
|
||||
* "https-server1-"
|
||||
* keyPrefix - prefix added to the beginning of the key database example: "
|
||||
* "https-server1-"
|
||||
* secmodName - name of the security module database (usually "secmod.db").
|
||||
* readOnly - Boolean: true if the databases are to be openned read only.
|
||||
* nocertdb - Don't open the cert DB and key DB's, just initialize the
|
||||
* Volatile certdb.
|
||||
* nomoddb - Don't open the security module DB, just initialize the
|
||||
* PKCS #11 module.
|
||||
* forceOpen - Continue to force initializations even if the databases cannot
|
||||
* be opened.
|
||||
*/
|
||||
static SECStatus
|
||||
nss_Init(const char *configdir, const char *certPrefix, const char *keyPrefix, const char *secmodName, PRBool readOnly, PRBool nodb)
|
||||
nss_Init(const char *configdir, const char *certPrefix, const char *keyPrefix,
|
||||
const char *secmodName, PRBool readOnly, PRBool noCertDB,
|
||||
PRBool noModDB, PRBool forceOpen)
|
||||
{
|
||||
SECStatus status;
|
||||
SECStatus rv = SECFailure;
|
||||
@ -220,28 +242,45 @@ nss_Init(const char *configdir, const char *certPrefix, const char *keyPrefix, c
|
||||
goto loser;
|
||||
RNG_SystemInfoForRNG();
|
||||
|
||||
status = nss_OpenCertDB(configdir, certPrefix, readOnly);
|
||||
if (status != SECSuccess) {
|
||||
if (!nodb) goto loser;
|
||||
if (noCertDB) {
|
||||
status = nss_OpenVolatileCertDB();
|
||||
if (status != SECSuccess) {
|
||||
goto loser;
|
||||
}
|
||||
} else {
|
||||
status = nss_OpenCertDB(configdir, certPrefix, readOnly);
|
||||
if (status != SECSuccess) {
|
||||
if (!forceOpen) goto loser;
|
||||
status = nss_OpenVolatileCertDB();
|
||||
if (status != SECSuccess) {
|
||||
goto loser;
|
||||
}
|
||||
}
|
||||
|
||||
status = nss_OpenKeyDB(configdir, keyPrefix, readOnly);
|
||||
if (status != SECSuccess) {
|
||||
if (!forceOpen) goto loser;
|
||||
}
|
||||
}
|
||||
|
||||
status = nss_OpenKeyDB(configdir, keyPrefix, readOnly);
|
||||
if (status != SECSuccess) {
|
||||
if (!nodb) goto loser;
|
||||
if (noModDB) {
|
||||
status = nss_OpenVolatileSecModDB();
|
||||
if (status != SECSuccess) {
|
||||
goto loser;
|
||||
}
|
||||
} else {
|
||||
status = nss_OpenSecModDB(configdir, secmodName);
|
||||
if (status != SECSuccess) {
|
||||
if (!forceOpen) goto loser;
|
||||
status = nss_OpenVolatileSecModDB();
|
||||
if (status != SECSuccess) {
|
||||
goto loser;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
status = nss_OpenSecModDB(configdir, secmodName);
|
||||
if (status != SECSuccess) {
|
||||
goto loser;
|
||||
}
|
||||
|
||||
rv = SECSuccess;
|
||||
|
||||
|
||||
loser:
|
||||
if (rv != SECSuccess)
|
||||
NSS_Shutdown();
|
||||
@ -251,20 +290,24 @@ loser:
|
||||
SECStatus
|
||||
NSS_Init(const char *configdir)
|
||||
{
|
||||
return nss_Init(configdir, "", "", SECMOD_DB, PR_TRUE, PR_FALSE);
|
||||
return nss_Init(configdir, "", "", SECMOD_DB, PR_TRUE,
|
||||
PR_FALSE, PR_FALSE, PR_FALSE);
|
||||
}
|
||||
|
||||
SECStatus
|
||||
NSS_InitReadWrite(const char *configdir)
|
||||
{
|
||||
return nss_Init(configdir, "", "", SECMOD_DB, PR_FALSE, PR_FALSE);
|
||||
return nss_Init(configdir, "", "", SECMOD_DB, PR_FALSE,
|
||||
PR_FALSE, PR_FALSE, PR_FALSE);
|
||||
}
|
||||
|
||||
SECStatus
|
||||
NSS_Initialize(const char *configdir, const char *certPrefix, const char *keyPrefix, const char *secmodName, PRBool readOnly)
|
||||
NSS_Initialize(const char *configdir, const char *certPrefix,
|
||||
const char *keyPrefix, const char *secmodName,
|
||||
PRBool readOnly, PRBool noCertDB, PRBool noModDB, PRBool forceOpen)
|
||||
{
|
||||
return nss_Init(configdir, certPrefix, keyPrefix,
|
||||
secmodName, readOnly, PR_TRUE);
|
||||
return nss_Init(configdir, certPrefix, keyPrefix, secmodName,
|
||||
readOnly, noCertDB, noModDB, forceOpen);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user