java.lang.SecurityException: signer information does not match signer information of other classes in the same package in PowerMock

huangapple go评论66阅读模式
英文:

java.lang.SecurityException: signer information does not match signer information of other classes in the same package in PowerMock

问题

当使用PowerMockito.mockStatic(Test.class)时,其中Test.class是一个已签名的jar文件的一部分,我遇到了SecurityException的问题。
这发生在java.lang.ClassLoader.checkCerts(ClassLoader.java:898)。
是否有办法在测试中避免证书检查?
我正在使用powermock-mockito 1.6.4版本。无法弄清楚如何解决这个问题。在这里有任何帮助吗?

英文:

When using PowerMockito.mockStatic(Test.class), where Test.class is part of the jar which is signed, I am getting SecurityException.
This happens at java.lang.ClassLoader.checkCerts(ClassLoader.java:898)
Is there anyway to avoid cert check in tests.
I am using powermock-mockito 1.6.4 version. Not able to figure out how to resolve this issue. Any help here.

答案1

得分: 2

Powermock库版本1.6.4存在一个bug,当模拟一个位于已签名JAR文件中的类时会失败。将powermock库升级到1.6.6可以解决这个问题。

英文:

Powermock lib version 1.6.4 has a bug where it fails when mocking a class which is part of signed jar. Upgrading the powermock lib to 1.6.6 solved this issue.

答案2

得分: 0

我遇到了一个类似的问题,但与powermock依赖项的详细信息不同,

"java.lang.SecurityException: 类的签名信息与同一包中其他类的签名信息不匹配"

当我搜索时,几乎所有人都说了相同的事情像这个链接

这意味着您在同一个包中有两个或更多类具有不同的签名数据。通常这意味着这些类来自不同的JAR文件,其中一个被签名,而另一个没有。

我尝试更改依赖版本,但没有奏效。但是当我将Maven版本从3.6.3降级到使用3.0.5时,一切都正常工作。

英文:

I got a similar issue but with different details with the powermock dependency,

> "java.lang.SecurityException: class ""'s signer information does not match signer information of other classes in the same package"

when i searched, almost people said the same things like this link

> It means that you have two or more classes in the same package with different signature data. Usually that means the classes come from different JARs, one of which is signed and the other is unsigned.

I tried to change the dependency version but it doesn't work.
but when I downgrade the maven version from 3.6.3v to use 3.0.5v. Everything is working fine.

huangapple
  • 本文由 发表于 2020年7月28日 00:04:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/63119112.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定