I am using IBM Websphere 6 JRE for running appication. I am getting below error when trying to generate private key
Generating a AES key Keysize: 256
algorithm = "AES" ,charset = "UTF8",chiper = "AES/CBC/PKCS5Padding", keyLen = 256;
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.lang.J9VMInternals.initialize(J9VMInternals.java:222)
at javax.crypto.KeyGenerator.a(Unknown Source)
at javax.crypto.KeyGenerator.<init>(Unknown Source)
at javax.crypto.KeyGenerator.getInstance(Unknown Source)
at com.hmsa.ebiz.encryption.Encryption.generateKey(Encryption.java:93)
at com.hmsa.ebiz.encryption.run.GenPrivKey.main(GenPrivKey.java:46)
Caused by: java.lang.SecurityException: Cannot set up certs for trusted CAs
at javax.crypto.b.<clinit>(Unknown Source)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
... 5 more
Caused by: java.lang.SecurityException: Jurisdiction policy files are not signed by trusted signers!
at javax.crypto.b.a(Unknown Source)
at javax.crypto.b.a(Unknown Source)
at javax.crypto.b.access$600(Unknown Source)
at javax.crypto.b$0.run(Unknown Source)
at java.security.AccessController.doPrivileged(AccessController.java:251)
... 8 more
Unlimited strength file should be installed to resolve this issue. Also upgrade the java version to JDK 7 in my case.
Steps to follow to resolve encryption issue.
1) Install JDK 1.7.
2)For Java Projectin eclipse point the right JDK version for compiler and run-time.
3)http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html
4)Download the policy files from above link local_policy & US_export_policy.
5) Replace the policy files in java home directory under security folder Ex: C:\Program Files\Java\jdk1.7.0_79\jre\lib\security\ and
6)C:\Program Files\Java\jre7\lib\security\
7)Now restart the websphere server and Place the two policy files in classpath for the java project.
8)Program should be generating the Key & encrypting it.