Docker openjdk java AES 解密报错

java AES 解密报错

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)

定位是 AES-ECB解密JCE无限制权限策问题

Java版本

openjdk version "1.8.0_212"
OpenJDK Runtime Environment (IcedTea 3.12.0) (Alpine 8.212.04-r0)
OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)

进入容器查看Java路径

echo $JAVA_HOME

 找到policy路径

 

docker替换jar包

# jre替换local_policy.jar和US_export_policy.jar JCE无限制权限策
COPY UnlimitedJCEPolicyJDK8/local_policy.jar /usr/lib/jvm/java-1.8-openjdk/jre/lib/security/policy/limited/local_policy.jar
COPY UnlimitedJCEPolicyJDK8/US_export_policy.jar /usr/lib/jvm/java-1.8-openjdk/jre/lib/security/policy/limited/US_export_policy.jar
COPY UnlimitedJCEPolicyJDK8/local_policy.jar /usr/lib/jvm/java-1.8-openjdk/jre/lib/security/policy/unlimited/local_policy.jar
COPY UnlimitedJCEPolicyJDK8/US_export_policy.jar /usr/lib/jvm/java-1.8-openjdk/jre/lib/security/policy/unlimited/US_export_policy.jar

资源下载

JCE Unlimited Strength Jurisdiction Policy Files for JDK/JRE 8 Download (oracle.com)

 

参考文章

Docker openjdk java AES 解密报错_无政策限制权限文件jdk8-CSDN博客

 

posted @ 2024-05-22 18:36  bookc  阅读(58)  评论(0编辑  收藏  举报