2017-10-13 159 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