JCE无限制权限策略文件,Illegal key size or default parameters,JCE Unlimited Strength Jurisdiction Policy files

加解密报错

java.security.InvalidKeyException: Illegal key size or default parameters
  • 报错原因
    密钥长度受限制,java运行时环境读到的是受限的policy文件;
    文件位于${java_home}/jre/lib/security下,这种限制是因为美国对软件出口的控制。

  • 解决办法
    去掉这种限制,需要下载Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files
    下载解压后,替换${java_home}/jre/lib/security/ 下面的local_policy.jar和US_export_policy.jar;记得先备份原来的

  • MAC路径:

/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/jre/lib/security

  • jdk8对应下载地址

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

Poi报错,通过升级jdk解决

org.apache.poi.EncryptedDocumentException: 
Export Restrictions in place - please install JCE Unlimited Strength Jurisdiction Policy files
  • 报错原因
    这个问题很容易联想到上面这个JCE文件,结果发现替换了也还是不行,需要升级JDK,具体的可以参考第二个链接

  • 解决方法
    我们从1.8.0_131升级到了1.8.0_191

参考

how to solve org.apache.poi.EncryptedDocumentException: Export Restrictions in place - please install JCE Unlimited Strength Jurisdiction Policy files

How to avoid installing “Unlimited Strength” JCE policy files when deploying an application?

你可能感兴趣的:(JCE无限制权限策略文件,Illegal key size or default parameters,JCE Unlimited Strength Jurisdiction Policy files)