Dear friends

First of all, sorry for my "Pocahontas" English. English is not my natural
language.
Well, I'm facing a problem on access a digital certificate inside a smart
card in an applet Java running on Firefox. In other words: I have an applet
java that needs to access a PKCS#11 certificate in order to digitally sign a
file before upload it. My applet uses JSS 3.4 (jss34.jar) and I have
installed some DLLs in the client side (jss3.dll, libnspr4.dll, libplc4.dll
and libplds4.dll in Firefox folder).
My certificate is visible in Firefox certificates window. You can see in
http://img3.imageshack.us/img3/7387/screenhz.png
http://img706.imageshack.us/img706/3694/screen2lj.png

With this scenario, I can run my applet (digitally signed), my applet can
access some certificate repositories from Firefox, but it cannot locate my
digital certificate in a smart card. 
When I run the code below, I see a list of three PK11Token objects: 
- Internal Crypto Services Token
- Internal Key Storage Token
- Builtin Object Token

First two have size 0 (zero). Third token has more than 100 CA certificates.

Where is my digital certificate? How can I access it? What I'm doing wrong? 
I spent more than a week in this problem without any solution. 
Any help will be welcome.

Here is the code snipet:

CryptoManager.initialize(".");
oCryptoMgr = CryptoManager.getInstance();
oDispKeys = new Hashtable();
Enumeration oAllCryptoTokens = oCryptoMgr.getAllTokens();

while(oAllCryptoTokens.hasMoreElements()) {
        CryptoToken oCryptoToken = (CryptoToken)
oAllCryptoTokens.nextElement();
        CryptoStore oCryptoStore = oCryptoToken.getCryptoStore();
        org.mozilla.jss.crypto.X509Certificate oCertsArray[] =
oCryptoStore.getCertificates();
        for(int i=0; i < oCertsArray.length; i++) {
        try {
        System.out.println("the certificate:
"+((PK11InternalTokenCert)oCertsArray[i]).getNickname() );
        PrivateKey oPKey = oCryptoMgr.findPrivKeyByCert(oCertsArray[i]);
            System.out.println("oPKey: "+oPKey );
            oDispKeys.put(oCertsArray[i].getNickname(),oPKey);
        } catch (ObjectNotFoundException  e){
                System.out.println("ObjectNotFoundException");
        } catch (Exception  e){
                e.printStackTrace();
        }
}

_____________________________________
Walter do Valle 


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

Reply via email to