我正在使用IBM Websphere 6 JRE来运行应用程序。我在尝试生成私钥时遇到错误
生成AES密钥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
答案 0 :(得分:0)
应安装无限强度文件以解决此问题。在我的例子中也将java版本升级到JDK 7.
解决加密问题的步骤。
1)安装JDK 1.7
2)对于Java Projectin eclipse指向适用于编译器和运行时的正确JDK版本。
3)http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html
4)从上面的链接local_policy&amp;中下载策略文件。 US_export_policy。
5)替换安全文件夹Ex:C:\ Program Files \ Java \ jdk1.7.0_79 \ jre \ lib \ security \和
下的java主目录中的策略文件
6)C:\ Program Files \ Java \ jre7 \ lib \ security \
7)现在重新启动websphere服务器并将两个策略文件放在java项目的类路径中。
8)程序应该生成Key&amp;加密它。