0%

Illegal key size

Illegal key size

在使用Cipher.init方法时突然报了一个异常java.security.InvalidKeyException: Illegal key size错误

1
2
3
4
5
6
java.security.InvalidKeyException: Illegal key size
at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1039)
at javax.crypto.Cipher.implInit(Cipher.java:805)
at javax.crypto.Cipher.chooseProvider(Cipher.java:864)
at javax.crypto.Cipher.init(Cipher.java:1396)
at javax.crypto.Cipher.init(Cipher.java:1327)

如何解决呢?需要去官方下载JCE无限制权限策略文件。

JDK7的下载地址: http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html
JDK8的下载地址: http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html

下载后解压,将local_policy.jar和US_export_policy.jar以及readme.txt三个文件复制到JAVA_HOME/jre/lib/security目录下覆盖原来的文件

欢迎关注我的其它发布渠道