Using existing NSS/NSPR DLLs from Firefox in another app on OS/2

Marty <[email protected]> Tue, 09 Feb 2010 00:16:30 -0800
Newsgroups gmane.comp.mozilla.devel.nspr
Message-ID <[email protected]>
I'm trying to use the NSS/NSPR DLLs from Firefox on OS/2 for another 
application (libpurple, an instant messaging library).  I'm linking up 
with them correctly (as far as I can tell), and initializing them in a 
standard way, but when I call SECMOD_AddNewModule, I get a GPF unless 
Firefox is already running on the system.  When I have Firefox running, 
everything seems to work well and I can make SSL connections through NSS 
successfully.

My app is GCC and GLIB-based.  Is it possible that the CRTL within the 
NSS DLLs are not getting initialized correctly?  Or is there some other 
problem in my initialization process?  Here is the code snippet that 
starts things up:

static void
ssl_nss_init_nss(void)
{
     char *lib;

     PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1);
     NSS_NoDB_Init(".");

     lib = g_strdup("nssckbi.dll");
     SECMOD_AddNewModule("Builtins", lib, 0, 0);
     /* GPF right on the above line if Firefox isn't running. */

     g_free(lib);
     NSS_SetDomesticPolicy();

     SSL_CipherPrefSetDefault(TLS_DHE_RSA_WITH_AES_256_CBC_SHA, 1);
     SSL_CipherPrefSetDefault(TLS_DHE_DSS_WITH_AES_256_CBC_SHA, 1);
     SSL_CipherPrefSetDefault(TLS_RSA_WITH_AES_256_CBC_SHA, 1);
     SSL_CipherPrefSetDefault(TLS_DHE_DSS_WITH_RC4_128_SHA, 1);
     SSL_CipherPrefSetDefault(TLS_DHE_RSA_WITH_AES_128_CBC_SHA, 1);
     SSL_CipherPrefSetDefault(TLS_DHE_DSS_WITH_AES_128_CBC_SHA, 1);
     SSL_CipherPrefSetDefault(SSL_RSA_WITH_RC4_128_SHA, 1);
     SSL_CipherPrefSetDefault(TLS_RSA_WITH_AES_128_CBC_SHA, 1);
     SSL_CipherPrefSetDefault(SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, 1);
     SSL_CipherPrefSetDefault(SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, 1);
     SSL_CipherPrefSetDefault(SSL_DHE_RSA_WITH_DES_CBC_SHA, 1);
     SSL_CipherPrefSetDefault(SSL_DHE_DSS_WITH_DES_CBC_SHA, 1);

     _identity = PR_GetUniqueIdentity("Purple");
     _nss_methods = PR_GetDefaultIOMethods();
}

-- 
[Reverse the parts of the e-mail address to reply.]