2017-10-13 117 views
0

我用NetBeans創建了一個Java UI,我需要包括外部jar並將它打包在一個jar中。包裝在獨特的jar與bouncyCastle.SecurityException

我得到了以下錯誤:

Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes

我用下面的代碼改變了build.xml

<target name="-post-jar"> 
    <jar jarfile="${dist.jar}" update="true"> 
     <zipgroupfileset dir="\Users\feli\Documents\bouncy\" excludes="META-INF/*.SF,META-INF/*.DSA,META-INF/*.RSA"/> 
      <manifest> 
      <attribute name="Main-Class" value="herramientascriptograficas.AplicacionCriptografica"/> 
     </manifest> 
    </jar> 
</target> 

但是,我得到了相同的結果。

我檢查罐子,我在META-INF:

META-INF feli$ ls BC1024KE.DSA BC1024KE_1.DSA BC2048KE.DSA BC2048KE_1.DSA MANIFEST.MF BC1024KE.SF BC1024KE_1.SF BC2048KE.SF BC2048KE_1.SF 

總之,build.xml不排除這些文件。你可以幫幫我嗎?

PS:我有一個蘋果,我試圖改變excludes ="META-INF/**/*",我得到了相同的結果

回答

2

BouncyCastle的罐子簽訂因爲implements a cryptographic provider

If your provider is supplying encryption algorithms through the Cipher KeyAgreement , KeyGenerator , Mac , or SecretKeyFactory classes, you will need to sign your JAR file so that the JCA can authenticate the code at runtime.

你重新打包的所有類到一個JAR,但你還沒有簽名。您正在使用BouncyCastle的的罐子的簽名文件,但他們現在是無效的,因爲你已經改變了內容

選項:

  • 登錄你的代碼代碼簽名證書

  • 部署也bcprov-jdk15on-1.xx.jar與應用

+0

謝謝,我部署我的bcprov-EXT-jdk15on-158.jar \t bcprov-jdk15on-158.jar應用,在路徑\ Users \ feli \ Documents \ bouncy \中。另一方面,我如何使用代碼簽名證書籤署我的代碼?謝謝 –

+0

在我發佈的鏈接中,您會找到簽署該jar的步驟。你將需要一個代碼簽名證書(並可能支付)。最簡單的解決方案是將所有軟件包打包在一個jar中,除了bouncycastle並分別分發它們 – pedrofb

相關問題