我使用BouncyCastle编写了一个小型解密工具。如果我使用控制台启动它,效果很好。
java -jar Decryptor.jar
但是,如果我通过双击jar文件启动它,则解密失败,但出现以下异常:
Caused by: java.lang.SecurityException: JCE cannot authenticate the provider BC
at javax.crypto.Cipher.getInstance(Cipher.java:656)
at javax.crypto.Cipher.getInstance(Cipher.java:595)
at logdecryptor.Decryptor.getDecryptedPrivateKey(Decryptor.java:93)
... 60 more
Caused by: java.util.jar.JarException: file:/C:/***/Decryptor.jar has unsigned entries - decryptor/Main.class
at javax.crypto.JarVerifier.verifySingleJar(JarVerifier.java:502)
at javax.crypto.JarVerifier.verifyJars(JarVerifier.java:363)
at javax.crypto.JarVerifier.verify(JarVerifier.java:289)
at javax.crypto.JceSecurity.verifyProviderJar(JceSecurity.java:164)
at javax.crypto.JceSecurity.getVerificationResult(JceSecurity.java:190)
at javax.crypto.Cipher.getInstance(Cipher.java:652)
... 62 more
我在Windows 10(非管理员用户)上运行,并且未使用管理员权限启动jar文件或命令行。为什么它的行为取决于我的启动方式?
修改:
这是一个行家构建。这是我的依赖项
<dependency>
<groupId>com.madgag.spongycastle</groupId>
<artifactId>pkix</artifactId>
<version>1.54.0.0</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk16</artifactId>
<version>1.46</version>
</dependency>
这里是我的插件
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>decryptor.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
运行目标:干净地编译汇编:单个