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

AW: [iaik-jce] Help with PKCS #12 PKCSException: Unable to decrypt PrivateKey



Hello,

if yet not done statically, you may have to add the IAIK provider.

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 Bill Price
Gesendet: Donnerstag, 31. August 2000 16:25
An: iaik-jce@iaik.at
Betreff: [iaik-jce] Help with PKCS #12 PKCSException: Unable to decrypt
PrivateKey


Hi. I am encountering difficulty unwrapping a PKCS 12 file. (This my first
attempt to explore PKCS #12 files.) I would appreciate any help or
suggestions. The P12 file was created using Netscape Communicator 4.7. The
password works, and the file loads into both Netscape and Microsoft
browsers. I have listed below the error message, the program, and the output
prior to the error. The output includes the “toString” display of the
unencrypted PKCS #12 object. I am using IAIK JCE version 2.5.1. Thanks.

Error Message:

Exception in thread "main" iaik.pkcs.PKCSException: Unable to decrypt
PrivateKey
!
        at iaik.pkcs.pkcs12.AuthenticatedSafe.decrypt(Unknown Source)
        at iaik.pkcs.pkcs12.PKCS12.decrypt(Unknown Source)
        at DisplayPKCS12.main(DisplayPKCS12.java:22)


PROGRAM::

import java.io.*;
import iaik.pkcs.PKCSException;
import iaik.pkcs.PKCSParsingException;
import iaik.pkcs.pkcs12.PKCS12;
import iaik.pkcs.pkcs12.CertificateBag;
import iaik.pkcs.pkcs12.KeyBag;

public class DisplayPKCS12 {

	public static void main(String [] argv) throws IOException,
PKCSParsingException, PKCSException {
		System.out.println("Reading Input File");
		FileInputStream is=new FileInputStream("mykeys.p12");
		PKCS12 myp12=new PKCS12(is);
		System.out.println("File Input Complete");
		char[] password= "mypassword".toCharArray();
		System.out.println(password);
		System.out.println(myp12);
		System.in.read();
		myp12.decrypt(password);
		System.in.read();
		System.out.println("File decrypted.");
		System.out.println(myp12.toString());
		System.in.read();
	}
}

Program Output:

java -classpath K:.;K:\iaik\iaik_jce_full.jar DisplayPKCS12
Reading Input File
File Input Complete
mypassword
PKCS#12 object:
Version: 3
AuthenticatedSafe: 0
mode: UNENCRYPTED

SafeBag: 0
PKCS8ShroudedKeyBag: not decrypted yet!

AuthenticatedSafe: 1
mode: PASSWORD_ENCRYPTED
Content encrypted with: PbeWithSHAAnd40BitRC2-CBC
No SafeBags or not decrypted yet.


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