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

[iaik-jce] Repost: How to read a PKCS12 File



Hi!

my 1st posting was unreadable in  some Mailreaders, so here is a (hopefully)
better version:

--------
I just created a PKCS12-File using the program demo.pkcs.pkcs12.PKCS12Create.
Now I want to read the Certificate in this file using the following lines of
code:


public static X509Certificate readCertificate (String Filename)

 {

  //read the certificate

  PKCS12 PKCS12_OBJECT = new PKCS12(new FileInputStream(Filename));

    // Decrypt the PKCS12-Object using the password "test"

   PKCS12_OBJECT.decrypt("test".toCharArray() );



    // Get the CertificateBags

    CertificateBag[] Cert_Bag = PKCS12_OBJECT.getCertificateBags();

  // Return the certificate

    return Cert_Bag[0].getCertificate();

 }

}

When I start this method with the generated file as parameter it throws the
Exception "iaik.pkcs.PKCSException: Unable to decrypt PrivateKey!" in the
decrypt-line.

Does anyone have any idea what the reason maybe? I'm a total newbie to
java/security/iaik... so any help would be nice.

Thanks in advance.

Markus Weimer



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