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

AW: [iaik-jce] PKCS12 and Netscape



Hello,

are you sure that the P12 file exported from Netscape only contains one
single cert respectively that the cert belonging to the private key is
included in cb[0]?

Regards,
Dieter Bratko

-----Ursprüngliche Nachricht-----
Von: iaik-jce-owner@iaik.tu-graz.ac.at
[mailto:iaik-jce-owner@iaik.tu-graz.ac.at]Im Auftrag von Carvalho, R.F.
de
Gesendet: Donnerstag, 19. Oktober 2000 16:24
An: 'Iaik Support'
Betreff: [iaik-jce] PKCS12 and Netscape


Hi,

I wrote a method that loads an .p12 file exported from Netscape and
generates an new .p12 file with the same contents, using the class PKCS12.
However Netscape could not be able to read the new file. Does anyone hava a
solution for it?

The following code shows how I did it:

private void decodePKCS12(String filename, String passwd) {
    try {
      PKCS12 pk = new PKCS12(new FileInputStream(filename));
      pk.decrypt(passwd.toCharArray());
      KeyBag kb = pk.getKeyBag();
      CertificateBag[] cb = pk.getCertificateBags();
      X509Certificate x509 = cb[0].getCertificate();
      CertificateBag[] cb2 = new CertificateBag[1];
      cb2[0] = new CertificateBag(cb[0].getCertificate());
      PKCS12 pkcs12 = new PKCS12(kb, cb2);
      pkcs12.encrypt(passwd.toCharArray());
      pkcs12.writeTo(new FileOutputStream("teste.p12"));
    }
    catch (Exception ex) {
      ex.printStackTrace();
      try {
        System.in.read();
      }
      catch (Exception exc) {}
    }
  }

Thanks in advance,

Rodrigo Carvalho
--
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



--
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