The following is my code to import a der encoded CA certificate.  I'm
getting a memory access down in CERT_ImportCerts.  It looks like it is
trying to access a pointer that is set to 0x3 instead of a valid
pointer.

So I have two questions is this code the correct way of doing it?
Does anyone have debug windows nss libraries that I can download so I
can see what is going on?  (compiling it has turned out to be a pain)

Note.  I've dynamically imported my symbols so they are prepended with
"my".

CERTCertDBHandle *dbHandle = NULL;
SECStatus rv;
std::string dbPath = m_ffDBLocation + "cert8.db";
CERTCertificate *importCert = NULL;
SECItem cert[1];

rv = myNSS_InitReadWrite(m_ffDBLocation.c_str());
if (rv != SECSuccess)
        {
        throw MethodException("NSS_InitReadWrite", myPORT_GetError());
        }

dbHandle = myCERT_GetDefaultCertDB();

//Load up the cert
cert[0].type = siDERCertBuffer;
cert[0].data = m_certBuffer;
cert[0].len = m_certBufferSize;

rv = myCERT_ImportCerts(dbHandle, certUsageSSLCA, 1, (SECItem**)&cert,
NULL,
                PR_TRUE, PR_TRUE, "MyCA");

if (rv == SECSuccess)
        {
        Logger::logMsg("Successfully imported certificate into firefox");
        }
else
        {
        int err = myPORT_GetError();
        Logger::logMsg("Firefox certificate load error %X(%d)", err, err);
        }

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

Reply via email to