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

AW: [iaik-jce] decrypting a .pfx file



Hello,

You may look at the second part of demo.pkcs.PKSC12Create:

      String fileName = ...;
      InputStream is = new FileInputStream(fileName);
      PKCS12 pkcs12 =   pkcs12 = new PKCS12(is);

      if (!pkcs12.verify(password))
        throw new PKCSException("Verification error!");

      pkcs12.decrypt(password);
      CertificateBag[] certBag = pkcs12.getCertificateBags();
      java.security.cert.Certificate[] certChain =
            CertificateBag.getCertificates(certBag);

      KeyBag kB = pkcs12.getKeyBag();
      PrivateKey pk = kB.getPrivateKey();


      X509Certificate[] certArray =
iaik.utils.Util.convertCertificateChain(certChain);
      int chainLen = certArray.length;
      for (int i = 0; i < chainLen; i++) {

        System.out.println(certArray[i].toString());
      }

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 Gert Verheyen
Gesendet: Mittwoch, 26. Juli 2000 14:54
An: 'iaik-jce@iaik.at'
Betreff: [iaik-jce] decrypting a .pfx file



	I'm trying to write a program for sending encrypted mails and I
would like to know how to get the private key out of the .pfx file into my
own keystore.
	Can you please provide me a sample program to extract the private
key from a PKCS12-file.
	It would be of great help.
	Thanks,
	hoping to hear from you soon
	GERT

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




smime.p7s