NSS_Init failure
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Hi, I am working on a project that requires hashing data. Unfortunately, I have been unable to get NSS to return a valid context for hashing. Here is the initialization code: 62 void chasm :: mylib_init() - - 63 { | 64 chasm_init_data.s_nspr_inited = PR_FALSE; | 65 chasm_init_data.s_nss_inited = PR_FALSE; | 66 | 67 if (!PR_Initialized()) |- 68 { || 69 PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); || 70 || 71 if (!PR_Initialized()) || 72 _nss_error(); || 73 || 74 chasm_init_data.s_nspr_inited = PR_TRUE; || 75 } | 76 | 77 if (!NSS_IsInitialized()) |- 78 { || 79 SECStatus status = NSS_Init(NULL); || 80 || 81 if (status != SECSuccess) || 82 _nss_error(); || 83 || 84 chasm_init_data.s_nss_inited = PR_TRUE; || 85 } | 86 } Note: _nss_error() throws an exception. The initialization of NSS fails (nothing is in PR_GetErrorText however). We plan on using SSL later, so a full NSS stack is necessary (saw an earlier post that pkcs#12 would do it, though to be honest I didn't see anything about how to hash with it in the docs). Any hints? Thanks in advance. - --Ben -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iQIbBAEBCAAGBQJLey/pAAoJEKaxavVX4C1XgycP9iOLylnAAClcAJCr8n8oaOm9 IDlM2O/AwQNuafnW4nHJvFOURv4aqrcRh3QNSK8DUUl6viWT70pMCQ5xIATgKptL QtqW9L9PjjLPdyb5mvwyr+XVuRP7bDL3mE1VrMPO5Fn4LdSWG5YwMH5al9nsCsLu Tgyr6v9QAM4D4lMXu2A+AYngFazudYvUIcH8kkGPOCynen3xs9AL22vlb7CIYacI fcmCpCIIja6o0N+gFj+OFfDUf5vM87b7njwvftdeJSWwpZQabHeW7295d/sySA8F GmAGzFYqHY2RFNCSG6ihtjKnUWWQR9QnhIf60UWQ2j0iRCaSEsdVryPCpnFrdFX2 14qdWrhpnqFzhqOd2bBrnSDhbMQQS7lcPUVj3RTVqIOt6C9JMs3SGFQDlZMshgsT MxztJoh7lrUBtOzwCQrG5KNQn6ZVdpYbZMKcMFhtcL0bYWwfjq2GcZB1qMyVxw6k aiXhbEAUHv8nzY/lcAJcgw1PPnHdbIZTy9Vx/SnE6+IYWiDK6N7CoYMmcL58Q21S HBIGIumyKzxuyl72Lks9q3kVtc9ZxrPhofZvujfx3xbvL8f4ivVdrbqnhgJB97nj iJMKj+zeelRBtNDcz8jCOwY83CUNAxBmMOInCmAKtIwxSJTxqg9M1c17sNRsICnq J8zJESwlBZatdaCVzow= =ucUj -END PGP SIGNATURE- -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto
Re: NSS_Init failure
On Tue, Feb 16, 2010 at 3:53 PM, Ben Boeckel maths...@gmail.com wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Hi, I am working on a project that requires hashing data. Unfortunately, I have been unable to get NSS to return a valid context for hashing. Here is the initialization code: 62 void chasm :: mylib_init() - - 63 { | 64 chasm_init_data.s_nspr_inited = PR_FALSE; | 65 chasm_init_data.s_nss_inited = PR_FALSE; | 66 | 67 if (!PR_Initialized()) |- 68 { || 69 PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); || 70 || 71 if (!PR_Initialized()) || 72 _nss_error(); || 73 || 74 chasm_init_data.s_nspr_inited = PR_TRUE; || 75 } | 76 | 77 if (!NSS_IsInitialized()) |- 78 { || 79 SECStatus status = NSS_Init(NULL); || 80 || 81 if (status != SECSuccess) || 82 _nss_error(); || 83 || 84 chasm_init_data.s_nss_inited = PR_TRUE; || 85 } | 86 } Note: _nss_error() throws an exception. The initialization of NSS fails (nothing is in PR_GetErrorText however). Hi Ben, You can call NSS_NoDB_Init(NULL), until your application needs to store certificates or private keys persistently in NSS databases. The reason your NSS_Init(NULL) call fails is that you're passing a NULL pointer to NSS_Init. Instead, you should pass a string that represents the pathname of the directory where you want to store your NSS databases. PR_GetErrorText is essentially an obsolete function now because it isn't adopted by NSPR clients. Call PR_GetError instead to get an error code, and look it up at http://www.mozilla.org/projects/security/pki/nss/ref/ssl/sslerr.html Wan-Teh -- dev-tech-crypto mailing list dev-tech-crypto@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-tech-crypto