[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[iaik-jce] PKCS exception



Hi,

 I want to generate a PKCS #12 to read x509certificates, generated by my
 java code, in Netscape browser.
 I write the following code:

 private void encodePKCS12(iaik.x509.X509Certificate[] cert, PrivateKey
privK, String
 passwd) {
     try {
       KeyBag keyBag = new KeyBag(privK);
       CertificateBag[] certBags = new CertificateBag[1];
       certBags[0] = new CertificateBag(cert[0]);

       PKCS12 pkcs12 = new PKCS12(keyBag, certBags, false);
       pkcs12.encrypt(passwd.toCharArray());
       pkcs12.writeTo(new FileOutputStream("kpn.p12"));
    } catch (Exception ex) {
       ex.printStackTrace();
     }
 }

 But when the method encrypt is performed I have the following exception:

 iaik.pkcs.PKCSException: Next tag no OCTET STRING!
        at iaik.pkcs.pkcs12.AuthenticatedSafe.<init>(AuthenticatedSafe.java)
        at iaik.pkcs.pkcs12.PKCS12.encrypt(PKCS12.java)
        at x509main.encodePKCS12(x509main.java:224)
        at x509main.<init>(x509main.java:49)
        at x509main.main(x509main.java:63)

Does some one have a clue on it?

Thanks,

Rodrigo

--
Mailinglist-archive at
http://jcewww.iaik.at/mailarchive/iaik-jce/jcethreads.html

To unsubscribe send an email to listserv@iaik.at with the folowing content:
UNSUBSCRIBE iaik-jce