aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2010-06-10 20:49:31 +0800
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-06-11 17:12:36 +0800
commit9e99aac0a660952488a91c40196be594367983b3 (patch)
tree72c4ef18fd4d9087e63ca1954cf34c5fb1f17b43
parent66a84a057d9526f6b4787bfc23b6c34cbd7b3605 (diff)
downloadgsoc2013-evolution-9e99aac0a660952488a91c40196be594367983b3.tar.gz
gsoc2013-evolution-9e99aac0a660952488a91c40196be594367983b3.tar.zst
gsoc2013-evolution-9e99aac0a660952488a91c40196be594367983b3.zip
Bug 585301 - Use camel_init() to initialize NSS consistently
The logic for working out what database to use should only be in one place.
-rw-r--r--smime/lib/e-cert-db.c59
1 files changed, 6 insertions, 53 deletions
diff --git a/smime/lib/e-cert-db.c b/smime/lib/e-cert-db.c
index 287d89aef4..a4fcbe4ac5 100644
--- a/smime/lib/e-cert-db.c
+++ b/smime/lib/e-cert-db.c
@@ -48,6 +48,9 @@
#include <glib/gi18n.h>
#include <glib/gstdio.h>
+
+#include <camel/camel.h> /* FIXME: this is where camel_init is defined; it shouldn't include everything else */
+
/* private NSS defines used by PSM */
/* (must be declated before cert.h) */
#define CERT_NewTempCertificate __CERT_NewTempCertificate
@@ -203,60 +206,10 @@ pk11_password (PK11SlotInfo* slot, PRBool retry, gpointer arg)
static void
initialize_nss (void)
{
- const gchar *data_dir;
- gchar *evolution_dir_path;
- gchar *nss_configstr;
- SECStatus status;
-
- data_dir = e_get_user_data_dir ();
-
-#ifdef G_OS_WIN32
- /* NSS wants filenames in system codepage */
- evolution_dir_path = g_win32_locale_filename_from_utf8 (data_dir);
-#else
- evolution_dir_path = g_strdup (data_dir);
-#endif
-
-#if NSS_VMAJOR > 3 || (NSS_VMAJOR == 3 && NSS_VMINOR >= 12)
- nss_configstr = g_strconcat ("sql:", evolution_dir_path, NULL);
-
- /* we initialize NSS here to make sure it only happens once */
- /* See: https://wiki.mozilla.org/NSS_Shared_DB,
- * particularly "Mode 3A". */
- status = NSS_InitWithMerge (
- nss_configstr, /* dest dir */
- "", "", /* new DB name prefixes */
- SECMOD_DB, /* secmod name */
- evolution_dir_path, /* old DB dir */
- "", "", /* old DB name prefixes */
- evolution_dir_path, /* unique ID for old DB */
- "Evolution S/MIME", /* UI name for old DB */
- 0); /* flags */
-#else
- nss_configstr = g_strdup (evolution_dir_path);
- status = NSS_InitReadWrite (nss_configstr);
-#endif
-
- if (status != SECSuccess) {
- status = NSS_Init (nss_configstr);
- if (status == SECSuccess)
- g_warning ("opening cert databases read-only");
- }
- if (status != SECSuccess) {
- status = NSS_NoDB_Init (nss_configstr);
- if (status == SECSuccess)
- g_warning ("initializing security library without cert databases.");
- }
- g_free (nss_configstr);
- g_free (evolution_dir_path);
-
- if (status != SECSuccess) {
- g_warning ("Failed all methods for initializing NSS");
- return;
- }
-
- NSS_SetDomesticPolicy();
+ /* Use camel_init() to initialise NSS consistently... */
+ camel_init(e_get_user_data_dir(), TRUE);
+ /* ... except for the bits we only seem to do here. FIXME */
PK11_SetPasswordFunc(pk11_password);
/* Enable ciphers for PKCS#12 */