Hi all, first time poster, long time reader
I am having a bit of an issue getting encryption to work in Java and I thought I'd ask for some tips. I have scoured the 'net by and far, read every thread here and still I am at a loss.
Background:
OS: WinXP
Java ver: j2sdk 1.4.2_01
IDE: Eclipse 3.0.1
Location: Canada (Maybe this is the trouble, dunno)
End goal: two way encryption to enable storage & retrieval of data for a school project
I have boiled down the error producing code to this:
package security;
import java.security.*;
import javax.crypto.*;
public class JCEProviderCheck {
public static void main(String[] args) {
Provider p = Security.getProvider("SunJCE");
System.out.println("My provider name is " + p.getName());
System.out.println("My provider version # is " + p.getVersion());
System.out.println("My provider info is " + p.getInfo());
System.out.println ("Home: " + System.getProperty("java.home"));
Security.addProvider(new com.sun.crypto.provider.SunJCE());
try {
Cipher c = Cipher.getInstance("DES", "SunJCE");
System.out.println("My Cipher algorithm name is " + c.getAlgorithm());
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
}
The output:
My provider name is SunJCE
My provider version # is 1.42
My provider info is SunJCE Provider (implements DES, Triple DES, AES, Blowfish, PBE, Diffie-Hellman, HMAC-MD5, HMAC-SHA1)
Home: C:\Program Files\j2sdk1.4.2_01\jre
java.lang.SecurityException: The provider SunJCE may not be signed by a trusted party
at javax.crypto.SunJCE_b.a(DashoA6275)
at javax.crypto.Cipher.a(DashoA6275)
at javax.crypto.Cipher.getInstance(DashoA6275)
at security.JCEProviderCheck.main(JCEProviderCheck.java:29)
I have checked and re-checked both java.policy and java.security plus made sure the following jars are in %JAVA_HOME%\lib\ext:
local_policy.jar
sunjce_provider.jar
US_export_policy.jar
Is there some glaringly obvious step I have overlooked? Any help would be greatly appreciated
-Kev