java 原因:sun.security.pkcs11.wrapper.PKCS11Exception:CKR_DATA_INVALID

xienkqul  于 2023-05-12  发布在  Java
关注(0)|答案(3)|浏览(259)

我有问题,我的应用程序,生成xml签署,但只是发生在Windows上,我没有问题,在Linux上,证明与jre 7和jre 8感谢提前。

java.security.ProviderException: sun.security.pkcs11.wrapper.PKCS11Exception: E

    at sun.security.pkcs11.P11Signature.engineSign(P11Signature.java:547)
    at java.security.Signature$Delegate.engineSign(Unknown Source)
    at java.security.Signature.sign(Unknown Source)
    at org.apache.xml.security.algorithms.implementations.SignatureBaseRSA.engineSign(SignatureBaseRSA.java:130)
    at org.apache.xml.security.algorithms.SignatureAlgorithm.sign(SignatureAlgorithm.java:173)
    at org.apache.xml.security.signature.XMLSignature.sign(XMLSignature.java:614)
    at bo.accl.clientelynx.Signer.firmar(Signer.java:283)
    at bo.accl.clientelynx.Signer.sign(Signer.java:168)
    at bo.accl.clientelynx.Signer.apply(Signer.java:350)
    at bo.accl.clientelynx.Signer.apply(Signer.java:61)
    at com.google.common.collect.Iterators$8.transform(Iterators.java:860)
    at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
    at bo.accl.clientelynx.App$17.doInBackground(App.java:1130)
    at bo.accl.clientelynx.App$17.doInBackground(App.java:1095)
    at javax.swing.SwingWorker$1.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at javax.swing.SwingWorker.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DATA_INVALID
    at sun.security.pkcs11.wrapper.PKCS11.C_Sign(Native Method)
    at sun.security.pkcs11.P11Signature.engineSign(P11Signature.java:538)
t9aqgxwy

t9aqgxwy1#

在搜索CKR_DATA_INVALID后,我发现错误为:
加密操作的明文输入数据无效。此返回值的优先级低于CKR_DATA_LEN_RANGE。
参见:http://www.cryptsoft.com/pkcs11doc/v220/pkcs11__all_8h.html#aCKR_DATA_INVALID
我的客人是你有一个编码问题与您的数据之间的windows和Linux。检查数据文件以查找无效的windows字符。

xam8gpfp

xam8gpfp2#

我在使用旧版本的p11-capi库时遇到过类似的问题。在我的例子中,我想使用一个新的签名算法(SHA 256 withRSA而不是SHA1 withRSA),并收到了相同的Java异常。这个异常不是很有帮助,所以花了很长时间,直到我发现这个问题已经在最近的库版本中得到了修复:https://risacher.org/p11-capi/

gr8qqesn

gr8qqesn3#

如果任何人在provider异常下遇到CKR_FUNCTION_FAILED,请检查别名是否正确。如果有多个别名,请在keystore中逐个检查。

相关问题