2015-05-22 44 views
0

我使用Maven爲創建在嵌在我的web應用程序登錄使用智能卡的PDF文檔一個JAR的項目。Maven的簽名的jar給出警告「未簽名的應用程序」

在我的pom.xml我使用maven-的jarsigner-插件如下:

<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的燈罩插件消息:

[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它是細手動檢查所得到的罐:

Niels-MBP:target niels$ jarsigner -verify my-applet.jar 
jar verified. 

罐子也驗證沒有在其他計算機上的問題。然而,當我包括我的web應用程序的jar,得到用戶的消息:「安全警告:你想運行此應用程序從上述請求的許可才能運行位置的Un簽名應用?。」

UPDATE:當我運行具有-verbose選項的jarsigner,所有的.class文件被標記爲sm(簽名驗證,條目在清單中列出)和缺少k選項(至少有一個證書在密鑰庫中找到)。這可能是錯誤的原因。 END UPDATE

該頁面通過HTTPS提供。罐子是在同一個域(甚至同一文件夾)的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> 

任何幫助,將不勝感激!

尼爾斯

+0

嗯......可能是我誤解了一件事情,但你應該小心Maven-shade-plugin的警告:''[警告] maven-shade-plugin檢測到有一些.class文件 [WARNING]存在於兩個或更多JAR。發生這種情況時,只有 [警告]之類的單一版本是在uberjar.'複製...,並檢查其類在不同的罐子? – khmarbaise

+0

謝謝。這些警告都指向構建的兩個瓶子中存在的類文件。一個是「獨立」測試版本,一個是嵌入在網站中的小程序。 – nielsr

回答

0

我購買的代碼簽名證書的公司 - Xolphin - 追查問題對我來說。它與密鑰庫中不正確添加的證書/別名有關。我重新創建了密鑰庫,問題消失了。

對於其他面臨同樣的警告:確保取消選中「保持我的計算機上的臨時文件」在您的Java設置(系統偏好設置 - >爪哇 - > Internet臨時文件 - >設置)。它使我在問題修復後進一步搜索,即使我爲不同版本的JAR文件使用了不同的文件名。