Nelson B wrote:
Umesh Bywar wrote:
Hi all:

Welcome to the list, Umesh.

   I am working on writing an xpcom component that checks which ciphers
work with a given target. So basically, I have a component which acts as
a SSL client and performs a handshake by setting a given cipher. I am
executing this in the context of the browser (and not as a independent
executable).

If your code is running in a mozilla-family browser, then your code
should let the browser do all the NSS initialization and shutdown.
You don't want to shutdown NSS in the middle of the running browser
because then the browser itself can no longer use NSS.
Your code should only ensure that it does not leak any object
references, so that when the browser shuts down NSS, NSS_Shutdown will
succeed at that time.
NSS_Shutdown will fail if there are still outstanding NSS object
references.  The browser itself probably has several such references,
which is one reason why it fails when you call it.
Here's a mozilla plugin code which will make sure NSS is initialized by PSM for you, This will replace your code calling NSS_NoDB_Init() and loading the builtins (PSM takes care of all that for you).

#include "nsIPK11Token.h"
.
.
.


nsCryptUtil::nsCryptUtil()
{
 nsresult rv;
 /* force NSS to initialize NSS PSM. Just about any old PSM component will
  * do here. We're using nsIPK11TokenDB because we will use it later */
 pk11TokenDB = do_GetService(NS_PK11TOKENDB_CONTRACTID, &rv);
}


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
dev-tech-crypto mailing list
dev-tech-crypto@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-crypto

Reply via email to