【发布时间】:2015-08-04 07:09:15
【问题描述】:
我正在将 Maven 用于一个项目,该项目创建一个嵌入在我的 Web 应用程序中的 JAR,以使用智能卡对 PDF 文档进行签名。
在我的 pom.xml 中,我使用 maven-jarsigner-plugin 如下:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>sign</id>
<goals>
<goal>sign</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<keystore>/path/to/my/keystore.jks</keystore>
<alias>my-key-alias</alias>
<storepass>********</storepass>
<keypass>********</keypass>
<verbose>true</verbose>
<certs>true</certs>
<arguments>
<argument>-tsa</argument>
<argument>https://timestamp.geotrust.com/tsa</argument>
</arguments>
</configuration>
</plugin>
项目构建良好,没有任何错误。对于 99%,它们只是 [INFO] 消息,除了来自 Maven Shade 插件的一些 [WARNING] 消息:
[WARNING] maven-shade-plugin has detected that some .class files
[WARNING] are present in two or more JARs. When this happens, only
[WARNING] one single version of the class is copied in the uberjar.
[WARNING] Usually this is not harmful and you can skeep these
[WARNING] warnings, otherwise try to manually exclude artifacts
[WARNING] based on mvn dependency:tree -Ddetail=true and the above
[WARNING] output
当我使用 CLI jarsigner 手动检查生成的 jar 时,这很好:
Niels-MBP:target niels$ jarsigner -verify my-applet.jar
jar verified.
jar 也可以在其他计算机上验证没有问题。但是,当我将 jar 包含在我的 Web 应用程序中时,用户会收到以下消息:“安全警告:您要运行此应用程序吗?来自上述位置的未签名应用程序正在请求运行权限。”
更新:当我使用 -verbose 选项运行 jarsigner 时,所有 .class 文件都标记为 sm(签名已验证,条目在清单中列出)并且缺少k 选项(在密钥库中至少找到一个证书)。这可能是错误的原因。 结束更新
页面通过 HTTPS 提供。 jar 与 HTML 页面位于同一个域(甚至同一个文件夹),并且包含如下:
<script src="https://www.java.com/js/deployJava.js"></script>
<script>
var attributes = {
id: 'myApplet',
code: 'nl.company.project.applet.MyAppletApplet',
archive: 'my-applet.jar',
width: 200,
height: 200
};
deployJava.runApplet(attributes, '1.7');
<script>
对此的任何帮助将不胜感激!
尼尔斯
【问题讨论】:
-
嗯...可能是我误解了一件事,但您应该小心 maven-shade-plugin 的警告:
[WARNING] maven-shade-plugin has detected that some .class files [WARNING] are present in two or more JARs. When this happens, only [WARNING] one single version of the class is copied in the uberjar....并检查哪些类在不同的 jar 中? -
谢谢。警告都指向存在于构建的两个 jar 中的类文件。一种是“独立”测试版本,一种是嵌入网站的小程序。
标签: java maven jar jarsigner signed-applet