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

[iaik-jce] PKCS#12 and Microsoft Internet Explorer



I am evaluating IAIK-JCE for my company and am having a little problem
beginning.  After exporting a public key from IE 5.0 to a PKCS#12 file, I am
trying to use IAIK-JCE to get to the public key.  Yet, every time I try, I
get a "iaik.pkcs.PKCSException: Unable to decrypt PrivateKey!"  The password
is correct.  Here is the code:

import iaik.pkcs.pkcs12.*;
import java.io.*;
import java.applet.Applet;
import java.awt.*;
import iaik.java.security.*;
import iaik.security.provider.IAIK;

public class Test extends Applet
{
	TextField filename = new TextField("C:\\My Documents\\cert2.pfx",
20);
	TextField password = new TextField("p", 20);
	Button doIt = new Button("Do it");
	TextField output = new TextField(20);
	
	public void start()
	{
		password.setEchoChar('*');
		add(filename);
		add(password);
		add(doIt);
		add(output);
		Security.insertProviderAt(new IAIK (), 1);
		IAIK.addAsProvider(true);
	}
	
	public boolean action(Event e, Object o)
	{
		String caption = (String)o;
		if(e.target instanceof Button)
			if(caption == "Do it")
			{
				output.setText(openPKCS12());
			}
		return true;
	}
	
	private String openPKCS12()
	{
		try{
			PKCS12 pfx = new PKCS12(new
FileInputStream(filename.getText()));
			PrivateKey pk;
			pfx.decrypt(password.getText().toCharArray());
			return "Yes";
		}
		catch(Exception e){
			return e.toString();
		}
	}
}

Has anyone else ran into this problem?

Aaron McKenzie-Brown
Group Leader, iLumin Corp.
--
Mailinglist-archive at http://jcewww.iaik.tu-graz.ac.at/mailarchive/iaik-jce/maillist.html

To unsubscribe send an email to listserv@iaik.tu-graz.ac.at with the folowing content: UNSUBSCRIBE iaik-jce