User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:18.104.22.168) Gecko/2009021910 Firefox/3.0.7 (.NET CLR 3.5.30729) Build Identifier: I'm in the process of porting over certificate path building code from using Sun's API to using JSS as we are gradually migrating all of our crypto over to JSS/NSS. I'm running some tests with CryptoManager.buildCertificateChain(X509Certificate leaf). If I grab a cert out of the db and pass it, everything is fine. If I want to chain a CA (either subCA with root in the DB or root) everything is fine. The CAs probably work fine as they get imported first due to the conversion problem. If I have a byte containing a certificate and would like to build a chain to see if it is in my hierarchy I need to get that certificate into an instance of the interface org.mozilla.jss.crypto.X509Certificate to pass to buildCertificateChain. The problem is, you can't seem to instantiate one of these in any way if you are holding some bytes. I can ASN1 decode the bytes into a org.mozilla.jss.pkix.cert.Certificate but that doesn't help. According to the JSS FAQ (http://www.mozilla.org/projects/security/pki/jss/faq.html#convertPkix) I can call Cryptomanager.importCertPackage() and pass the DER encoded certificate/PKCS7 bytes and it will return the leaf cert. The problem is the only way it will work and return the leaf cert is if it has a matching key in the token. The javadoc implies this and looking at the code for the native import function in http://mxr.mozilla.org/security/source/security/jss/org/mozilla/jss/PK11Finder.c, the comments all say that's the intended behavior. If I would like to build a chain to an SSL server's certificate, for example, I can't as I would never have its key. I know the NSS db can hold arbitrary non-CA certs (in Firefox, for ssl exceptions and in thunderbird for another user's email cert). It seems odd that I can't just present a random certificate to JSS and have it build the chain if it's in a hierarchy I know/trust or throw an exception if it's not. So the RFE is for a way to at least attempt to chain any arbitrary certificate and get an error if I don't have the CAs instead of an error that I don't have the private key. Reproducible: Always
I looked into this a little more. NSS's certutil can import certs that don't have keys in the DB and it does it by calling PK11_ImportCert (defined at http://mxr.mozilla.org/security/source/security/nss/lib/pk11wrap/pk11pub.h#595) and passes CK_INVALID_HANDLE as the key handle. Would it be possible to add another importCertPackage method to CryptoManager that calls the underlying import methods in the way that certutil -A does?
You need to log in before you can comment on or make changes to this bug.