ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# **退款遇到的问题** 有个别客户遇到,原因是秘钥太长导致  java中使用AES对称加密后,请求报错: Caused by: java.lang.RuntimeException: java.security.InvalidKeyException: Illegal key size or default parameters at com. 原因是美国的出口限制,Sun通过权限文件(local\_policy.jar、US\_export\_policy.jar)做了相应限制。密钥长度最大128,对于需要更大长度的场景则会抛出上面异常。 问题log ~~~ Caused by: java.lang.RuntimeException: java.security.InvalidKeyException: Illegal key size or default parameters at com.btzh.util.AESUtil.encrypt(AESUtil.java:18) at com.btzh.service.impl.SiThirdSystemServiceImpl.mapSystemParams(SiThirdSystemServiceImpl.java:32) at com.btzh.resource.SiThirdSystemResource.mapSystemParams(SiThirdSystemResource.java:41) ... 43 common frames omitted Caused by: java.security.InvalidKeyException: Illegal key size or default parameters at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1026) at javax.crypto.Cipher.implInit(Cipher.java:801) at javax.crypto.Cipher.chooseProvider(Cipher.java:864) at javax.crypto.Cipher.init(Cipher.java:1249) at javax.crypto.Cipher.init(Cipher.java:1186) at com.btzh.util.AESUtil.encrypt(AESUtil.java:15) ~~~ 解决办法是下载Oracle官方网站上的无政策限制权限文件,下载链接: ~~~ jdk8:https://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html ~~~ 下载后将`%JAVA_HOME%\jre\lib\security`中的`local_policy.jar` 和`US_export_policy.jar`替换为下载包中的的`local_policy.jar` 和`US_export_policy.jar`。 在CentOs 7.6环境查看jdk安装目录 ![](https://img.kancloud.cn/c2/34/c2344cfe3a39c98305a8e5de3aff86dc_911x504.png) 在/usr/java/jdk1.8.0\_131/jre/lib/security下替换local\_policy.jar和US\_export\_policy.jar tips 官方的密钥应该再128之内