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

[iaik-jce] pkcs#12 decryption failing

I was looking through the archives , and saw benoit's post:
>I must read this file and extract the private key and the certificate from

>I managed to read part of the file. It contains 2 Authenticatedsafe.

>Authenticatedsafe Nr 0 is unencrypted. It contains 1 SafeBag, type 
>PKCS8ShroudedKeyBag. I suppose it is the private key.
>It is encrypted with PbeWithSHAAnd3-KeyTripleDES-CBC algorithm.

>I know the password associated with the private key.

>Authenticatedsafe Nr 1 is encrypted with PbeWithSHAAnd40BitRC2-CBC.
>So I can't read its content. Nevertheless I suppose it is the

>How can I extract the PrivateKey and the Certificate in order to be able to
>encrypt, decrypt and sign mails with them?

 I have almost the same exact problem (and a solution wasn't posted...so
here I am asking the question again).

I generated a p12 file from the openssl command tool (openssl.org) that
works with Internet Explorer, but when I run the following code:

 public static void main(String[] argv)
	FileInputStream fis= null;

		fis = new FileInputStream("user4.p12");
		System.out.println("made fileinputstream");

		PKCS12 greatstuff = new PKCS12(fis);
		System.out.println("pkcs12 object created: "+

		System.out.println("about to decode the file....");
		char[] password = "password".toCharArray();
		System.out.println("just decoded it....: "+
-----it faults on the the decrypt line.  this is the output that I get:

C:\cvs\new-stuff\vote\src>java signTest
made fileinputstream
pkcs12 object created: PKCS#12 object:
Version: 3
AuthenticatedSafe: 0
Content encrypted with: PbeWithSHAAnd40BitRC2-CBC
No SafeBags or not decrypted yet.

AuthenticatedSafe: 1

SafeBag: 0
PKCS8ShroudedKeyBag: not decrypted yet!

about to decode the file....
an exception was thrown
iaik.pkcs.PKCSException: java.security.NoSuchAlgorithmException:
ters not available
        at iaik.pkcs.pkcs12.AuthenticatedSafe.decrypt(Unknown Source)
        at iaik.pkcs.pkcs12.PKCS12.decrypt(Unknown Source)
        at signTest.main(signTest.java:28)

I've looked all through the openssl command line docs, looked through their
mailing lists, looked through the mailing list here, and couldn't find an
answer...so, please help me out there.  thanks


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