【问题标题】:Maven build fails while using JCE with " The jurisdiction policy files are not signed by a trusted signer!"使用 JCE 时,Maven 构建失败,“管辖权策略文件未由受信任的签名者签名!”
【发布时间】:2015-01-16 01:34:23
【问题描述】:

我在我的项目中使用 JCE 进行加密和解密。我已经在 $JAVA_HOME/jre/lib/security 下安装了必要的 java 安全 jar。同样在我的eclipse开发环境中,我指向了正确的jre。在 Eclipse 中一切正常。但是当我使用 maven 构建项目时,它会失败并出现以下异常

 The jurisdiction policy files are not signed by a trusted signer!

到目前为止尝试过的事情。

通过在其他任何事情之前初始化以下代码块来尝试破解

 try {
    Field field = Class.forName("javax.crypto.JceSecurity").getDeclaredField("isRestricted");
    field.setAccessible(true);
    field.set(null, java.lang.Boolean.FALSE);
} catch (ClassNotFoundException | NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) {
    ex.printStackTrace(System.err);
}

还尝试通过添加以下插件来更改 pom.xml

<plugins>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-enforcer-plugin</artifactId>
 <version>1.1.1</version>
 <executions>
     <execution>
         <id>enforce</id>
            <configuration>
                <rules>
                  <evaluateBeanshell>
                     <condition>javax.crypto.Cipher.getMaxAllowedKeyLength("AES") > 128</condition>
                  </evaluateBeanshell>
             </rules>
         </configuration>
         <goals>
             <goal>enforce</goal>
         </goals>
      </execution>
 </executions>
</plugin>

我已确认策略 jar 的版本与我机器上的 Java 版本匹配。有没有办法配置 maven 以使用这些罐子? (不必使用像 Bouncy Castle 这样的其他库)谢谢。

【问题讨论】:

    标签: java security maven permissions jce


    【解决方案1】:

    下载Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 以获得无限强度版本并将其用于构建和运行时。

    【讨论】:

      猜你喜欢
      • 2012-04-02
      • 2016-06-23
      • 1970-01-01
      • 1970-01-01
      • 2021-10-07
      • 2019-09-03
      • 2011-04-05
      • 1970-01-01
      • 2021-05-22
      相关资源
      最近更新 更多