{{userInfo.nickname}}
用户设置 退出登录

{{wikiTitle}}

退款问题

💰退款遇到的问题

✋ 有个别客户遇到,原因是秘钥太长导致

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,对于需要更大长度的场景则会抛出上面异常。

🤔 问题log1

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)

🤔 问题log2

"app": "Crmeb_admin",
                    "timestamp":"2022-03-12 02:54:47.822",
                    "level": "ERROR",
                    "thread": "http-nio-20000-exec-29",
                    "class": "c.z.s.service.impl.CallbackServiceImpl",
                    "message": "微信退款回调异常,e==》pad block corrupted" }

{
                    "app": "Crmeb_admin",
                    "timestamp":"2022-03-12 02:54:47.822",
                    "level": "ERROR",
                    "thread": "http-nio-20000-exec-29",
                    "class": "c.z.s.service.impl.CallbackServiceImpl",
                    "message": "微信退款回调失败==>{returnXml=<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xm

✅ 解决办法是下载Oracle官方网站上的无政策限制权限文件,下载链接:

jdk8:https://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html

✅ 也可以通过我准备的网盘下载-快不用注册Oracle

链接: https://pan.baidu.com/s/1JvIJNhGb4-DbowAVbPVW6w 提取码: java

🚗 下载后将%JAVA_HOME%\jre\lib\security中的local_policy.jarUS_export_policy.jar替换为下载包中的的local_policy.jarUS_export_policy.jar

在CentOs 7.6环境查看jdk安装目录

在/usr/java/jdk1.8.0_131/jre/lib/security下替换local_policy.jar和US_export_policy.jar

tips 官方的密钥应该再128之内

{{cateWiki.like_num}}人点赞
0人点赞
评论({{cateWiki.comment_num}}) {{commentWhere.order ? '评论从旧到新':'评论从新到旧'}} {{cateWiki.page_view_num}}人看过该文档
评论(0) {{commentWhere.order ? '评论从旧到新':'评论从新到旧'}} 162人看过该文档
评论
{{item.user ? item.user.nickname : ''}} (自评)
{{item.content}}
{{item.create_time}} 删除
{{item.like ? item.like.like_num : 0}} {{replyIndex == index ? '取消回复' : '回复'}}
评论
{{items.user ? items.user.nickname : '暂无昵称'}} (自评)
{{items.content}}
{{items.create_time}} 删除
{{items.like ? items.like.like_num : 0}} {{replyIndexJ == (index+'|'+indexJ) ? '取消回复' : '回复'}}
评论
目录
  • {{item}}